CREATE TABLE COMPARATIVOPLAREALINF
(
	NRCOMPARATIVOPLAREALINF NUMBER NOT NULL,
	NRCTRLCOMPARATIVOPLAREALINF NUMBER NOT NULL,
	CDFILIAL VARCHAR2(4) NOT NULL,
	CDCIA VARCHAR2(4) NOT NULL,
	NRVOO VARCHAR2(5) NOT NULL,
	CDTRECHO VARCHAR2(4) NOT NULL,
   DTDECOLAGEM DATE NOT NULL,
	IDREGISTRO VARCHAR(30) NOT NULL
	CONSTRAINT CKC_COMPARATIVOPLAREALINF_IDRE CHECK(IDREGISTRO IN ('REALIZADO', 'PLANEJADO')),
   CDCLASSE VARCHAR2(4) NOT NULL,   
   NRTABPRECO VARCHAR2(3) NOT NULL,
   NRSERVICOCIAFILIPRECO NUMBER NOT NULL,
   CDCICLO VARCHAR2(4) NOT NULL,
   NRSEQPRECO NUMBER NULL,   
   DTINIVIGSE DATE NULL,
   DTFIMVIGSE DATE NULL,
   IDPROPORCAO VARCHAR2(1) NULL,   
   QTPROPORCAO FLOAT(126) NULL,
   QTSERVICO FLOAT NOT NULL,
   CDMANCIA VARCHAR2(4) NOT NULL,
   NRSERVICOCIAFILI NUMBER NOT NULL,
   CDSUBGRU VARCHAR2(10) NOT NULL,
   NRSEQSUBGRUSEMAM NUMBER NOT NULL,
   IDPROPSUBSEMAM VARCHAR2(1) NULL,  
   QTPROPSUBSEMAM FLOAT(126) NULL,
   DTINIVGSUMA DATE NULL, 
   DTFIMVGSUMA DATE NULL,
   QTSUBGRUPO FLOAT NOT NULL,   
   CDPRODUTO VARCHAR2(10) NOT NULL,
   QTPRODUTO FLOAT NOT NULL,
   CDRECEITA VARCHAR2(10) NULL,
   NRNIVEL NUMBER NULL,
   VRCUSTOUNIT FLOAT NOT NULL,
   NRORG             NUMBER 	     DEFAULT         SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
   IDATIVO           VARCHAR2(1)     DEFAULT 'S' NOT NULL
      CONSTRAINT CKC_COMPARATIVOPLAREALINF_IDAT 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_COMPARATIVOPLAREALINF PRIMARY KEY (NRCOMPARATIVOPLAREALINF)
)
/

CREATE INDEX IDX_COMPARATIVOPLAREALINF01 ON COMPARATIVOPLAREALINF (NRCTRLCOMPARATIVOPLAREALINF)
/

CREATE INDEX IDX_COMPARATIVOPLAREALINF02 ON COMPARATIVOPLAREALINF (NRCTRLCOMPARATIVOPLAREALINF, CDFILIAL, CDCIA, NRVOO, CDTRECHO, DTDECOLAGEM)
/