CREATE TABLE PRAZOFORNEXPEDFIL 
(   
    NRPRAZOFORNEXPEDFIL 	NUMBER 	        NOT NULL,
    CDFORNECED          	VARCHAR2(21)    NOT NULL,
    CDFILIAL            	VARCHAR2(4)     NOT NULL,
    QTDIASPRAZOEXPED    	FLOAT           NOT NULL,
	NRORG             		NUMBER 	      	DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 		NOT NULL,
    IDATIVO           		VARCHAR2(1)     DEFAULT 'S' 					NOT NULL
		CONSTRAINT CKC_IDATIVO_PRAZOFORNEXPEDFIL CHECK (IDATIVO IN ('S','N')),
    DTINCLUSAO        DATE                  NULL,
    DTULTATU          DATE                  NULL,
    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 PK_PRAZOFORNEXPEDFIL PRIMARY KEY (NRPRAZOFORNEXPEDFIL),
		CONSTRAINT UN_PRAZOFORNEXPEDFIL UNIQUE (CDFORNECED, CDFILIAL),
		CONSTRAINT FKCMP00605PRAZOFORNEXPFIL_FORN  FOREIGN KEY (CDFORNECED) 
                             REFERENCES FORNECEDOR (CDFORNECED) ON DELETE CASCADE,
		CONSTRAINT FKCMP00606PRAZOFORNEXPFIL_FIL  FOREIGN KEY (CDFILIAL) 
                             REFERENCES FILIAL (CDFILIAL) ON DELETE CASCADE
)
/
CREATE INDEX CMP00605_FK ON PRAZOFORNEXPEDFIL (CDFORNECED)
/

CREATE INDEX CMP00606_FK ON PRAZOFORNEXPEDFIL (CDFILIAL)
/

CREATE SEQUENCE SEQ_PRAZOFORNEXPEDFIL INCREMENT BY 1 MINVALUE 1
/

ALTER TABLE ITEMAUTF ADD QTDIASPRZEXPEDAF FLOAT
/