
CREATE TABLE ANEXOLANCPED(	 
    NRANEXOLANCPED 		VARCHAR2(5)		NOT NULL,
	CDFILIAL 			VARCHAR2(4)     NOT NULL, 
	NRPEDIDO 			VARCHAR2(10)    NOT NULL, 
	DSLINKANEXOPED 		VARCHAR2(200) 	NOT NULL, 
	NMANEXOLANCPED 		VARCHAR2(200) 	NOT NULL, 
	NRORG             NUMBER 	      DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 		NOT NULL,
    IDATIVO           VARCHAR2(1)     DEFAULT 'S'					NOT NULL,
    DTINCLUSAO        DATE            DEFAULT SYSDATE,
    DTULTATU          DATE            DEFAULT SYSDATE,
    NRORGINCLUSAO     NUMBER          DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')		NULL,
    CDOPERINCLUSAO    VARCHAR2(12)    DEFAULT '1' 					NULL,
    NRORGULTATU       NUMBER          DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')		NULL,
    CDOPERULTATU      VARCHAR2(12)    DEFAULT '1',
		CONSTRAINT CKC_IDATIVO_ANEXOLANCPED CHECK (IDATIVO IN ('S','N')), 
		CONSTRAINT PK_ANEXOLANCPED PRIMARY KEY (NRANEXOLANCPED, CDFILIAL, NRPEDIDO),
		CONSTRAINT FKPED00461FILIAL_ANEXOLANCPED FOREIGN KEY (CDFILIAL) REFERENCES FILIAL(CDFILIAL),
		CONSTRAINT FKPED00462PEDIDO_ANEXOLANCPED FOREIGN KEY (NRPEDIDO, CDFILIAL) REFERENCES PEDIDO(NRPEDIDO, CDFILIAL)ON DELETE CASCADE
)
/
CREATE INDEX PED00461_FK ON ANEXOLANCPED (CDFILIAL)
/
CREATE INDEX PED00462_FK ON ANEXOLANCPED (NRPEDIDO,CDFILIAL)
/