ALTER TABLE FCT_PARAMETROGERAL ADD IDBLOQCARENCMAXI CHAR(1) DEFAULT 'N' NOT NULL
/

ALTER TABLE FCT_PARAMETROGERAL ADD CONSTRAINT CKC_IDBLOQCARENCMAXI CHECK (IDBLOQCARENCMAXI IN ('S', 'N'))
/

ALTER TABLE FCT_CARENCIAPERFIL MODIFY NRDAISMAXCARENCIA NULL
/

ALTER TABLE FCT_CARENCIAPERFIL ADD NRPARCELASMAX NUMBER
/

ALTER TABLE FCT_CARENCIAPERFIL ADD VRPERCMAXATE FLOAT
/

ALTER TABLE FCT_CARENCIAOPER MODIFY NRDAISMAXCARENCIA NULL
/

ALTER TABLE FCT_CARENCIAOPER ADD NRPARCELASMAX NUMBER
/

ALTER TABLE FCT_CARENCIAOPER ADD VRPERCMAXATE FLOAT
/

CREATE TABLE FCT_CARENCIAFAIXADESC (
    NRCARENCIAFAIXADESC NUMBER NOT NULL,
    NRCARENCIAPERFIL    NUMBER,
    NRCARENCIAOPER      NUMBER,
    NRPARCELASMAX       NUMBER NOT NULL,
    VRPERCDESCDE        FLOAT NOT NULL,
    VRPERCDESCATE       FLOAT NOT NULL,
    IDATIVO             VARCHAR2(1) DEFAULT 'S' NOT NULL,
    CDOPERADOR          VARCHAR2(12),
    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			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')		NULL,
    CDOPERULTATU        VARCHAR(12)		DEFAULT '1',
		CONSTRAINT CKC_IDATIVO_FCT_CARENCFXDESC CHECK (IDATIVO IN ('S','N'))
)
/

ALTER TABLE FCT_CARENCIAFAIXADESC ADD CONSTRAINT PK_FCT_CARENCIAFAIXADESC PRIMARY KEY (NRCARENCIAFAIXADESC)
/

CREATE INDEX SM00372_FK ON FCT_CARENCIAFAIXADESC (NRCARENCIAPERFIL ASC)
/

ALTER TABLE FCT_CARENCIAFAIXADESC ADD CONSTRAINT FKSM00372CARENCIAFAIXA_PERFIL
    FOREIGN KEY (NRCARENCIAPERFIL) REFERENCES FCT_CARENCIAPERFIL (NRCARENCIAPERFIL) ON DELETE CASCADE
/

CREATE INDEX SM00373_FK ON FCT_CARENCIAFAIXADESC (NRCARENCIAOPER ASC)
/

ALTER TABLE FCT_CARENCIAFAIXADESC ADD CONSTRAINT FKSM00373CARENCIAFAIXA_OPER
    FOREIGN KEY (NRCARENCIAOPER) REFERENCES FCT_CARENCIAOPER (NRCARENCIAOPER) ON DELETE CASCADE
/

ALTER TABLE FCT_CONTRATO ADD IDAGRUPPARC VARCHAR2(1) DEFAULT '1' NOT NULL
/

ALTER TABLE FCT_CONTRATO ADD CONSTRAINT CKC_CONTRATO_IDAGRUPPARC CHECK (IDAGRUPPARC IN ('1', '2', '3'))
/

UPDATE FCT_CONTRATO
   SET IDAGRUPPARC = '2'
 WHERE IDGERARATEIO = 'S'
/

ALTER TABLE FCT_CAPAPARAMFATESC ADD IDAGRUPPARC VARCHAR2(1) DEFAULT '1' NOT NULL
/

ALTER TABLE FCT_CAPAPARAMFATESC ADD CONSTRAINT CKC_PARAMFATESC_IDAGRUPPARC CHECK (IDAGRUPPARC IN ('1', '2', '3'))
/

UPDATE FCT_CAPAPARAMFATESC
   SET IDAGRUPPARC = '2'
 WHERE IDGERARATEIO = 'S'
/

ALTER TABLE FCT_NEGOCIACAOCONTRATO ADD CDTRIBPRODPADR VARCHAR2(20)
/

ALTER TABLE FCT_NEGOCIACAOCONTRATO ADD CDPAISFAT VARCHAR2(4)
/

ALTER TABLE FCT_NEGOCIACAOCONTRATO ADD SGESTADOFAT VARCHAR2(2)
/

ALTER TABLE FCT_NEGOCIACAOCONTRATO ADD CDMUNICIPIOFAT VARCHAR2(4)
/

CREATE INDEX SM00374_FK ON FCT_NEGOCIACAOCONTRATO (CDPAISFAT ASC,SGESTADOFAT ASC, CDMUNICIPIOFAT ASC)
/

ALTER TABLE FCT_NEGOCIACAOCONTRATO ADD CONSTRAINT FKSM00374NEGOCIACAOCONT_MUNIC
    FOREIGN KEY (CDPAISFAT, SGESTADOFAT, CDMUNICIPIOFAT) REFERENCES MUNICIPIO (CDPAIS, SGESTADO, CDMUNICIPIO)
/

ALTER TABLE FCT_NEGOCIACAOPROPOSTA ADD CDTRIBPRODPADR VARCHAR2(20)
/

ALTER TABLE FCT_MEDICAOFATURA ADD NRESTRUTURAM NUMBER
/

ALTER TABLE FCT_MEDICAOFATURA ADD CDTRIBPRODPADR VARCHAR2(20)
/

ALTER TABLE FCT_MEDICAOFATURA ADD CDPAISFAT VARCHAR2(4)
/

ALTER TABLE FCT_MEDICAOFATURA ADD SGESTADOFAT VARCHAR2(2)
/

ALTER TABLE FCT_MEDICAOFATURA ADD CDMUNICIPIOFAT VARCHAR2(4)
/

CREATE INDEX SM00375_FK ON FCT_MEDICAOFATURA (NRESTRUTURAM ASC)
/

ALTER TABLE FCT_MEDICAOFATURA ADD CONSTRAINT FKSM00375MEDFATU_ESTRUTURAM
    FOREIGN KEY (NRESTRUTURAM) REFERENCES ESTRUTURAM (NRESTRUTURAM)
/

CREATE INDEX SM00376_FK ON FCT_MEDICAOFATURA (CDPAISFAT ASC,SGESTADOFAT ASC, CDMUNICIPIOFAT ASC)
/

ALTER TABLE FCT_MEDICAOFATURA ADD CONSTRAINT FKSM00376MEDFATU_MUNICIPIO
    FOREIGN KEY (CDPAISFAT, SGESTADOFAT, CDMUNICIPIOFAT) REFERENCES MUNICIPIO (CDPAIS, SGESTADO, CDMUNICIPIO)
/

ALTER TABLE FCT_FATURACONT ADD NRESTRUTURAM NUMBER
/

ALTER TABLE FCT_FATURACONT ADD CDTRIBPRODPADR VARCHAR2(20)
/

ALTER TABLE FCT_FATURACONT ADD CDPAISFAT VARCHAR2(4)
/

ALTER TABLE FCT_FATURACONT ADD SGESTADOFAT VARCHAR2(2)
/

ALTER TABLE FCT_FATURACONT ADD CDMUNICIPIOFAT VARCHAR2(4)
/

CREATE INDEX SM00377_FK ON FCT_FATURACONT (NRESTRUTURAM ASC)
/

ALTER TABLE FCT_FATURACONT ADD CONSTRAINT FKSM00377FATUCONT_ESTRUTURAM
    FOREIGN KEY (NRESTRUTURAM) REFERENCES ESTRUTURAM (NRESTRUTURAM)
/

CREATE INDEX SM00378_FK ON FCT_FATURACONT (CDPAISFAT ASC,SGESTADOFAT ASC, CDMUNICIPIOFAT ASC)
/

ALTER TABLE FCT_FATURACONT ADD CONSTRAINT FKSM00378FATUCONT_MUNICIPIO
    FOREIGN KEY (CDPAISFAT, SGESTADOFAT, CDMUNICIPIOFAT) REFERENCES MUNICIPIO (CDPAIS, SGESTADO, CDMUNICIPIO)
/

ALTER TABLE FCT_DADOSNF ADD IDNATUOPER VARCHAR2(2)
/

ALTER TABLE FCT_DADOSNF ADD CONSTRAINT CKC_DADOSNF_IDNATUOPER CHECK (IDNATUOPER IN ('01', '02', '03', '04', '05', '06', '07', '08'))
/