ALTER TABLE PRATFILI ADD IDCOMPLEXIDADE VARCHAR2(30) DEFAULT 'BAIXA' NOT NULL
/
ALTER TABLE PRATFILI ADD 
   CONSTRAINT CKC_IDCOMPLEXIDADE_PRATFILI CHECK (IDCOMPLEXIDADE IN ('BAIXA','MEDIA','ALTA'))
/
ALTER TABLE PRATFILI ADD IDPREPREPARO VARCHAR2(1) DEFAULT 'N' NOT NULL
/
ALTER TABLE PRATFILI ADD 
   CONSTRAINT CKC_IDPREPREPARO_PRATFILI CHECK (IDPREPREPARO IN ('S','N'))
/
ALTER TABLE PRATFILI ADD IDCOR VARCHAR2(30) NULL
/
CREATE TABLE PRATFILITIPOPRAT (
	CDFILIAL 			VARCHAR2(4) 												NOT NULL,
	CDFILAUXPRAT 		VARCHAR2(4) 												NOT NULL,
	CDPRATO 			VARCHAR2(10) 												NOT NULL,
	CDTIPOPRAT 			VARCHAR2(2) 												NOT NULL,
	NRORG 				NUMBER 			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 	NOT NULL,
	IDATIVO 			VARCHAR2(1) 	DEFAULT 'S' 								NOT NULL
		CONSTRAINT CKC_IDATIVO_PRATFILITIPOPRAT 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_PRATFILITIPOPRAT PRIMARY KEY (CDFILIAL, CDFILAUXPRAT, CDPRATO, CDTIPOPRAT)
)
/
ALTER TABLE PRATFILITIPOPRAT
	ADD CONSTRAINT FKPLA01149PRATFILI FOREIGN KEY (CDFILAUXPRAT, CDPRATO, CDFILIAL)
		REFERENCES PRATFILI (CDFILAUXPRAT, CDPRATO, CDFILIAL) ON DELETE CASCADE
/
ALTER TABLE PRATFILITIPOPRAT
	ADD CONSTRAINT FKPLA01150TIPOPRAT FOREIGN KEY (CDTIPOPRAT)
		REFERENCES TIPOPRAT (CDTIPOPRAT) ON DELETE CASCADE 