CREATE TABLE PRODLISTAPRECOCARDTRAB
(
	NRPRODLISTAPRECOCARDTRAB NUMBER   NOT NULL,
	NRCARDAPIOTRAB NUMBER  			  NOT NULL,
	NRPRODLISTAPRECOTCO NUMBER        NOT NULL,
	NRLISTAPRECOTCO NUMBER  		  NOT NULL,
	IDESCOLHIDO VARCHAR2(1)  		  DEFAULT 'N' NOT NULL,
	IDIMPORTADO VARCHAR2(1)  		  DEFAULT 'N' NOT NULL, 
	CDPRODESTO VARCHAR2(10)  		  NOT NULL,
	VRCUSTO FLOAT  			          NOT NULL,
	VRPEACRESCIMO FLOAT  			  NOT NULL,
	CDMARCA VARCHAR2(5)  			  NOT NULL,
	CDREGIAO VARCHAR2(3)  			  NOT NULL,
	CDFORNECED VARCHAR2(21) 		  NOT NULL,
	CDPRODUTO VARCHAR2(10) 			  NOT NULL,
	DTINIVALITM DATE 				  NOT NULL,         
	DTFINVALITM DATE 				  NOT NULL,        
	VRPRECUNIITM FLOAT 				  NOT NULL,
	VRPRECOITMPI FLOAT 				  NOT NULL,
	VRPRECECOITM FLOAT 				  NOT NULL,
	VRFATOCONV FLOAT 				  NOT NULL,
	IDFORNECEDOROL VARCHAR2(1) 	  	  NOT NULL,
	IDCUSTOPELAMEDIA VARCHAR2(1)      NOT NULL,
	IDFORNEPRIOTCO VARCHAR2(1)        NOT NULL,
	CDFILIAL VARCHAR2(4) 			  NULL,
	NRCOLEPRECO VARCHAR2(10) 		  NULL,
	DTCUSTO DATE 					  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_PRODLISPRECCARDTRB CHECK (IDATIVO IN ('S','N')),
	   CONSTRAINT PK_NRPRODLISTAPRECOCARDTRAB PRIMARY KEY (NRPRODLISTAPRECOCARDTRAB),
	   CONSTRAINT CKC_IDESCOLHIDO_PRLISPRECARDTR CHECK (IDESCOLHIDO IN ('S', 'N')),
	   CONSTRAINT CKC_IDIMPORTADO_PRLISPRECARDTR CHECK (IDIMPORTADO IN ('S', 'N'))
)
/

ALTER TABLE PRODLISTAPRECOCARDTRAB
    ADD CONSTRAINT FKPLA01307CARDAPIOTRAB FOREIGN KEY  (NRCARDAPIOTRAB)
       REFERENCES CARDAPIOTRAB (NRCARDAPIOTRAB) ON DELETE CASCADE
/

CREATE INDEX PLA01307_FK ON PRODLISTAPRECOCARDTRAB(NRCARDAPIOTRAB)
/

ALTER TABLE PRODLISTAPRECOCARDTRAB
    ADD CONSTRAINT FKPLA01308LISTAPRECOTCO FOREIGN KEY  (NRLISTAPRECOTCO)
       REFERENCES LISTAPRECOTCO(NRLISTAPRECOTCO)
/

CREATE INDEX PLA01308_FK ON PRODLISTAPRECOCARDTRAB(NRLISTAPRECOTCO)
/

CREATE INDEX IDXPRODLISTAPRECOCARDTRAB01 ON PRODLISTAPRECOCARDTRAB(NRCARDAPIOTRAB, CDPRODESTO)
/

ALTER TABLE PRODUTOCARDTRAB ADD NRPRODLISTAPRECOCARDTRAB NUMBER NULL
/

ALTER TABLE PRODUTOCARDTRAB MODIFY CDMARCA NULL
/ 

ALTER TABLE CARDAPIOTRAB DROP CONSTRAINT FKPLA01174LISTAPRECOTCO
/
DROP INDEX FKPLA01174LISTAPRECOTCO
/

ALTER TABLE RECEPRATCARDTRAB ADD IDINCLUIDO VARCHAR2(1) NULL
/

ALTER TABLE RECEPRATCARDTRAB ADD CONSTRAINT CKC_IDINCLUIDO_RECEPRATCARDTRA 
CHECK (IDINCLUIDO IN ('S', 'N'))
/