CREATE TABLE FCT_SEGUROCONTRATO (
    NRSEGUROCONTRATO        NUMBER          NOT NULL,
    NRAPOLICE               VARCHAR2(100)   NOT NULL,
    DSMODALIDADE            VARCHAR2(500),
    DTINISEGURO             DATE            NOT NULL,
    DTFINSEGURO             DATE            NOT NULL,
    VRTAXASEGURO            FLOAT,
    VRAPOLICE               FLOAT           NOT NULL,
    NRPARCCORRETORA         NUMBER,
    NRPARCSEGURADORA        NUMBER          NOT NULL,
    NRSEQCONTRATO           NUMBER          NOT NULL,
    IDVIGENTE               VARCHAR2(1)     NOT NULL,
    IDATIVO                 VARCHAR2(1)     DEFAULT 'S' NOT NULL,
		CONSTRAINT CKC_IDATIVO_FCT_SEGUROCONT CHECK (IDATIVO IN ('S','N')),
    NRORG                   NUMBER          DEFAULT NVL(SYS_CONTEXT('nrorg_ctx', 'nrorg'), 1) NOT NULL,
    DTINCLUSAO              DATE            DEFAULT SYSDATE NOT NULL,
    NRORGINCLUSAO           NUMBER          DEFAULT NVL(SYS_CONTEXT('nrorg_ctx', 'nrorg'), 1) NOT NULL,
    CDOPERINCLUSAO          VARCHAR(12)     NOT NULL,
    DTULTATU                DATE			DEFAULT SYSDATE,
    NRORGULTATU             NUMBER,
    CDOPERULTATU            VARCHAR(12)
)
/

ALTER TABLE FCT_SEGUROCONTRATO ADD CONSTRAINT PK_FCT_SEGUROCONTRATO PRIMARY KEY (NRSEGUROCONTRATO)
/

CREATE INDEX SM00369_FK ON FCT_SEGUROCONTRATO (NRSEQCONTRATO ASC)
/

ALTER TABLE FCT_SEGUROCONTRATO ADD CONSTRAINT FKSM00369FCTSEGCONT_FCTCONT FOREIGN KEY (NRSEQCONTRATO) REFERENCES FCT_CONTRATO (NRSEQCONTRATO)
/

CREATE INDEX SM00370_FK ON FCT_SEGUROCONTRATO (NRPARCCORRETORA ASC)
/

ALTER TABLE FCT_SEGUROCONTRATO ADD CONSTRAINT FKSM00370FCTSEGCONT_PARCCORR FOREIGN KEY (NRPARCCORRETORA) REFERENCES PARCNEGOCIO (NRPARCNEGOCIO)
/

CREATE INDEX SM00371_FK ON FCT_SEGUROCONTRATO (NRPARCSEGURADORA ASC)
/

ALTER TABLE FCT_SEGUROCONTRATO ADD CONSTRAINT FKSM00371FCTSEGCONT_PARCSEGUR FOREIGN KEY (NRPARCSEGURADORA) REFERENCES PARCNEGOCIO (NRPARCNEGOCIO)
/

ALTER TABLE FCT_SEGUROCONTRATO ADD CONSTRAINT CK_IDVIGENTE_SEGUROCONT CHECK (IDVIGENTE IN ('S', 'N'))
/