CREATE TABLE FCT_VENCIMENTOPREV
(
    NRVENCIMENTOPREV      NUMBER                 NOT NULL,
    NRSEQORCAMENTO        NUMBER                 NULL    ,
    NRGRUPOFATURAORCA     NUMBER                 NULL    ,
    NRAPURACAO            NUMBER                 NULL    ,
    QTDIASVENCIMENTO      NUMBER                 NULL    ,
    DTINICOMPET           DATE                   NULL    ,
    DTFINCOMPET           DATE                   NULL    ,
    DTVENCIMENTO          DATE                   NULL    ,
    VRVENCIMENTO          FLOAT                  NULL    ,
    NRORG                 NUMBER 		 DEFAULT 	 SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
    IDATIVO               VARCHAR2(1)     	 DEFAULT 'S' NOT NULL
      CONSTRAINT CKC_IDATIVO_FCT_VENCPREV CHECK (IDATIVO IN ('S','N')),
    DTINCLUSAO            DATE                   NULL,
    DTULTATU              DATE                   NULL,
    NRORGINCLUSAO         NUMBER             	 DEFAULT 1 NULL,
    CDOPERINCLUSAO        VARCHAR2(12)  	 DEFAULT '1' NULL,
    NRORGULTATU           NUMBER             	 DEFAULT 1 NULL,
    CDOPERULTATU          VARCHAR2(12)		 DEFAULT '1',
    CONSTRAINT PK_FCT_VENCIMENTOPREV PRIMARY KEY (NRVENCIMENTOPREV)
)
/
CREATE INDEX SM00197_FK ON FCT_VENCIMENTOPREV (NRSEQORCAMENTO ASC)
/
ALTER TABLE FCT_VENCIMENTOPREV
    ADD CONSTRAINT FKSM00197FCT_VENCIMENTOPREV FOREIGN KEY  (NRSEQORCAMENTO)
       REFERENCES FCT_ORCAMENTO (NRSEQORCAMENTO) ON DELETE CASCADE
/
CREATE INDEX SM00198_FK ON FCT_VENCIMENTOPREV (NRGRUPOFATURAORCA ASC)
/
ALTER TABLE FCT_VENCIMENTOPREV
    ADD CONSTRAINT FKSM00198FCT_VENCIMENTOPREV FOREIGN KEY  (NRGRUPOFATURAORCA)
       REFERENCES FCT_GRUPOFATURAORCA (NRGRUPOFATURAORCA) ON DELETE CASCADE
/
CREATE INDEX SM00199_FK ON FCT_VENCIMENTOPREV (NRAPURACAO ASC)
/
ALTER TABLE FCT_VENCIMENTOPREV
    ADD CONSTRAINT FKSM00199FCT_VENCIMENTOPREV FOREIGN KEY  (NRAPURACAO)
       REFERENCES FCT_APURACAO (NRAPURACAO)