CREATE TABLE ITCOMBGRUPOTPPRAT (
	NRITCOMBGRUPOTPPRAT NUMBER 														NOT NULL,
	NRCOMBGRUPOTPPRAT 	NUMBER 														NOT NULL,
	CDGRTIPOPR 			VARCHAR2(2) 												NOT NULL,
	CDFILAUXPRAT 		VARCHAR2(4) 												NOT NULL,
	CDPRATO 			VARCHAR2(10) 												NOT NULL,
	IDCOMBINACAO		VARCHAR2(30) 	DEFAULT 'OBRIGATORIO' 						NOT NULL
		CONSTRAINT CKC_IDCOMBINACAO_ITCOMBGRUPTPR CHECK (IDCOMBINACAO IN ('OBRIGATORIO', 'RESTRICAO')),
	NRORG 				NUMBER 			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 	NOT NULL, 
	IDATIVO 			VARCHAR2(1) 	DEFAULT 'S' 								NOT NULL 
		CONSTRAINT CKC_IDATIVO_ITCOMBGRUPOTPPRAT 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_ITCOMBGRUPOTPPRAT PRIMARY KEY (NRITCOMBGRUPOTPPRAT)
)
/
ALTER TABLE ITCOMBGRUPOTPPRAT ADD 
	CONSTRAINT FKPLA01144COMBGRUPOTPRAT FOREIGN KEY (NRCOMBGRUPOTPPRAT) 
        REFERENCES COMBGRUPOTPPRAT (NRCOMBGRUPOTPPRAT) ON DELETE CASCADE
/
CREATE INDEX FKPLA01144COMBGRUPOTPRAT ON ITCOMBGRUPOTPPRAT (NRCOMBGRUPOTPPRAT)
/
ALTER TABLE ITCOMBGRUPOTPPRAT ADD 
    CONSTRAINT FKPLA01145GRTIPOPR FOREIGN KEY (CDGRTIPOPR) 
        REFERENCES GRTIPOPR (CDGRTIPOPR) ON DELETE CASCADE
/
CREATE INDEX FKPLA01145GRTIPOPR ON ITCOMBGRUPOTPPRAT (CDGRTIPOPR)
/
ALTER TABLE ITCOMBGRUPOTPPRAT ADD 
    CONSTRAINT FKPLA01146PRATO FOREIGN KEY (CDFILAUXPRAT, CDPRATO) 
        REFERENCES PRATO (CDFILAUXPRAT, CDPRATO) ON DELETE CASCADE
/
CREATE INDEX FKPLA01146PRATO ON ITCOMBGRUPOTPPRAT(CDFILAUXPRAT, CDPRATO)