CREATE TABLE COMPCARDTRAB (
	NRCOMPCARDTRAB			NUMBER 														NOT NULL,
    NRCARDAPIOTRAB 			NUMBER														NOT NULL,
    NRDIACARDTRAB			NUMBER														NOT NULL,
	NRCONFIGCARDTRAB 		NUMBER														NOT NULL,
    CDFILAUXPRAT 			VARCHAR2(4)													NOT NULL,
	CDPRATO					VARCHAR2(10)												NOT NULL,
	VRPECONSCARDTRAB		FLOAT														NULL,
	NRORG 					NUMBER			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 	NOT NULL,
	IDATIVO 				VARCHAR2(1) 	DEFAULT 'S' 								NOT NULL
		CONSTRAINT CKC_IDATIVO_COMPCARDTRAB 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' 								NULL,
	CONSTRAINT PK_COMPCARDTRAB PRIMARY KEY (NRCOMPCARDTRAB),
	CONSTRAINT UN_COMPCARDTRAB UNIQUE (NRCARDAPIOTRAB, NRDIACARDTRAB, NRCONFIGCARDTRAB)
)
/
ALTER TABLE COMPCARDTRAB ADD
	CONSTRAINT FKPLA01085CARDAPIOTRAB FOREIGN KEY (NRCARDAPIOTRAB)
		REFERENCES CARDAPIOTRAB (NRCARDAPIOTRAB)
/
CREATE INDEX FKPLA01085CARDAPIOTRAB ON COMPCARDTRAB (NRCARDAPIOTRAB)
/
ALTER TABLE COMPCARDTRAB ADD
	CONSTRAINT FKPLA01086DIACARDTRAB FOREIGN KEY (NRDIACARDTRAB)
		REFERENCES DIACARDTRAB (NRDIACARDTRAB)
/
CREATE INDEX FKPLA01086DIACARDTRAB ON COMPCARDTRAB (NRDIACARDTRAB)
/
ALTER TABLE COMPCARDTRAB ADD
	CONSTRAINT FKPLA01087CONFIGCARDTRAB FOREIGN KEY (NRCONFIGCARDTRAB)
		REFERENCES CONFIGCARDTRAB (NRCONFIGCARDTRAB)
/
CREATE INDEX FKPLA01087CONFIGCARDTRAB ON COMPCARDTRAB (NRCONFIGCARDTRAB)
/
ALTER TABLE COMPCARDTRAB ADD
	CONSTRAINT FKPLA01088PRATO FOREIGN KEY (CDFILAUXPRAT, CDPRATO)
		REFERENCES PRATO (CDFILAUXPRAT, CDPRATO)
/
CREATE INDEX FKPLA01088PRATO ON COMPCARDTRAB (CDFILAUXPRAT, CDPRATO)