CREATE TABLE DIFAFNF(
	CDFILIAL VARCHAR2(04) NOT NULL,
	NRLANCTONF VARCHAR2(10) NOT NULL, 
	NRSEQITPROD VARCHAR2(04) NOT NULL,
	VRDIFITAFNF FLOAT NOT NULL,
		CONSTRAINT PK_DIFAFNF PRIMARY KEY (CDFILIAL, NRLANCTONF, NRSEQITPROD),
	 NRORG             NUMBER 	     DEFAULT         SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    IDATIVO           VARCHAR2(1)     DEFAULT 'S' NOT NULL
		CONSTRAINT CKC_IDATIVO_DIFAFNF 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'	
)
/
 
CREATE INDEX FIS00774_FK ON DIFAFNF (CDFILIAL ASC,NRLANCTONF ASC,NRSEQITPROD ASC)
/

ALTER TABLE DIFAFNF ADD CONSTRAINT FKFIS00774DIFAFNF
	FOREIGN KEY (CDFILIAL, NRLANCTONF, NRSEQITPROD) REFERENCES ITEMPRODUTO (CDFILIAL, NRLANCTONF, NRSEQITPROD) ON DELETE CASCADE
/
ALTER TABLE FORNECEDOR ADD IDGERAAJUSTEAFNF VARCHAR2(01) DEFAULT 'N'
	CONSTRAINT CKC_IDGERAAJUSTEAFNF_DIFAFNF CHECK (IDGERAAJUSTEAFNF IN ('N', 'S'))
/

ALTER TABLE FORNECEDOR ADD CDAJCTPAGDIFAFNF VARCHAR2(04)
/

CREATE INDEX FIS00775_FK ON FORNECEDOR (CDAJCTPAGDIFAFNF ASC)
/

ALTER TABLE FORNECEDOR ADD CONSTRAINT FKFIS00775FORNECEDOR 
	FOREIGN KEY (CDAJCTPAGDIFAFNF) REFERENCES TIPOAJPAGAR (CDAJUCTPAG)
/