ALTER TABLE PRODUTO ADD IDUTILRETPRODACAB VARCHAR2(1) DEFAULT 'N' NOT NULL
/
ALTER TABLE INSCRESTAD ADD IDDIFERICMSANT  VARCHAR2(01) DEFAULT 'N' NOT NULL
   CONSTRAINT CKC_IDDIFERICMSANT_INSCRESTAD CHECK (IDDIFERICMSANT IN ('S','N'))
/
CREATE TABLE DIFERICMSANTCFOP
(
   CDEMPRESA        	VARCHAR2(02)           NOT NULL,
   CDINSCESTA       	VARCHAR2(16)           NOT NULL,
   CDCFOPPADRAO     VARCHAR2(10)           NOT NULL,
   NRORG                       	NUMBER DEFAULT 	 SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
   DTINCLUSAO       	DATE                   NULL,
   DTULTATU         	DATE                   NULL,
   NRORGINCLUSAO    NUMBER                 DEFAULT 1 NULL,
   CDOPERINCLUSAO   VARCHAR2(12)           DEFAULT '1' NULL,
   NRORGULTATU      	NUMBER                 DEFAULT 1 NULL,
   CDOPERULTATU     	VARCHAR2(12)           DEFAULT '1',
	CONSTRAINT PK_DIFERICMSANTCFOP PRIMARY KEY (CDEMPRESA, CDINSCESTA, CDCFOPPADRAO)
)
/
CREATE INDEX FK_FIS00724 ON DIFERICMSANTCFOP (CDEMPRESA ASC, CDINSCESTA ASC)
/
ALTER TABLE DIFERICMSANTCFOP
    ADD CONSTRAINT FKFIS00724INSCREST FOREIGN KEY  (CDEMPRESA, CDINSCESTA)
       REFERENCES INSCRESTAD (CDEMPRESA, CDINSCESTA)  ON DELETE CASCADE
/
CREATE INDEX FK_FIS00725 ON DIFERICMSANTCFOP (CDCFOPPADRAO ASC)
/
ALTER TABLE DIFERICMSANTCFOP
    ADD CONSTRAINT FKFIS00725CFOPPADR FOREIGN KEY  (CDCFOPPADRAO)
       REFERENCES CFOPPADRAO (CDCFOPPADRAO)