CREATE TABLE VERSAORTPI 
(  
	CDVERSAO 			VARCHAR2(10) 	NOT NULL,
	DTINIVERSAO 		DATE 			NOT NULL,
	DTFINVERSAO 		DATE 			NOT NULL,
    NRORG 				NUMBER 			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
	IDATIVO 			VARCHAR2(1) 	DEFAULT 'S' NOT NULL,
		CONSTRAINT CKC_IDATIVO_VERSAORTPI 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',
      CONSTRAINT PK_VERSAORPTI PRIMARY KEY (CDVERSAO)  
)
/

CREATE TABLE DADOSRTPI
(
	CDVERSAO 			VARCHAR2(10) 	NOT NULL,
	DSFORMAFISICA 		VARCHAR2(4000),
	DSACONDICIONAMENTO 	VARCHAR2(4000),
	DSENRIQUECIMENTO 	VARCHAR2(4000),
	DSSUBSTITUTOS 		VARCHAR2(4000),
	DSCONTROLE 			VARCHAR2(4000),
	DSCONSERVACAO 		VARCHAR2(4000),
	DSRECOMENDACOES 	VARCHAR2(4000),
	DSESPECIE 			VARCHAR2(200),
	DSTIPOPRODUTO 		VARCHAR2(200),
	DSCLASSIFICACAO 	VARCHAR2(200),
    NRORG 				NUMBER 			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
	IDATIVO 			VARCHAR2(1) 	DEFAULT 'S' NOT NULL,
		CONSTRAINT CKC_IDATIVO_DADOSRTPI 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',
		CONSTRAINT PK_DADOSRTPI PRIMARY KEY (CDVERSAO)  
   
)
/

ALTER TABLE DADOSRTPI
    ADD CONSTRAINT FKMAN02318VERSAORTPI FOREIGN KEY  (CDVERSAO)
       REFERENCES VERSAORTPI (CDVERSAO) ON DELETE CASCADE