CREATE TABLE COMBGRUPOTPPRAT (
	NRCOMBGRUPOTPPRAT	NUMBER 														NOT NULL,
	CDGRTIPOPR 			VARCHAR2(2) 												NOT NULL,
	CDFILAUXPRAT 		VARCHAR2(4) 												NOT NULL,
	CDPRATO 			VARCHAR2(10) 												NOT NULL,
	NRORG 				NUMBER 			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 	NOT NULL, 
	IDATIVO 			VARCHAR2(1) 	DEFAULT 'S' 								NOT NULL 
		CONSTRAINT CKC_IDATIVO_COMBGRUPOTPPRAT 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_COMBGRUPOTPPRAT PRIMARY KEY (NRCOMBGRUPOTPPRAT)
)
/
ALTER TABLE COMBGRUPOTPPRAT ADD 
	CONSTRAINT FKPLA01142GRTIPOPR FOREIGN KEY (CDGRTIPOPR) 
		REFERENCES GRTIPOPR (CDGRTIPOPR) ON DELETE CASCADE
/
CREATE INDEX FKPLA01142GRTIPOPR ON COMBGRUPOTPPRAT (CDGRTIPOPR)
/
ALTER TABLE COMBGRUPOTPPRAT ADD 
	CONSTRAINT FKPLA01143PRATO FOREIGN KEY (CDFILAUXPRAT, CDPRATO) 
		REFERENCES PRATO (CDFILAUXPRAT, CDPRATO) ON DELETE CASCADE
/
CREATE INDEX FKPLA01143PRATO ON COMBGRUPOTPPRAT (CDFILAUXPRAT, CDPRATO)