CREATE TABLE ITEMPEDIDONF
(
    CDFILIAL    VARCHAR2(4)            NOT NULL,
    NRPEDIDO    VARCHAR2(10)           NOT NULL,
    NRITEMPED   VARCHAR2(10)           NOT NULL,
    NREXPEDICAO VARCHAR(10)            NOT NULL,
    NRLANCTONF  VARCHAR2(10)           NOT NULL,
    CDPRODUTO   VARCHAR2(10)           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_ITEMPEDIDONF CHECK (IDATIVO IN ('S','N')),
		CONSTRAINT PK_ITEMPEDIDONF PRIMARY KEY (CDFILIAL, NRPEDIDO, NRITEMPED, NREXPEDICAO),
		CONSTRAINT FKPED00462 FOREIGN KEY (CDFILIAL, NRPEDIDO, NRITEMPED)
			REFERENCES ITEMPEDIDO (CDFILIAL, NRPEDIDO, NRITEMPED)
)
/ 

CREATE INDEX PED00462_FK ON ITEMPEDIDONF(CDFILIAL ASC, NRPEDIDO ASC, NRITEMPED ASC)
/