CREATE TABLE FCT_JUSTIFCANCELAAPUR (
	   NRJUSTIFCANCELAAPUR  NUMBER	        NOT NULL, 
	   DSJUSTIFCANCELAAPUR  VARCHAR2(250)   NOT NULL, 
	   NRORG             	NUMBER 	        DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 		NOT NULL,
	   IDATIVO              VARCHAR2(1)     DEFAULT 'S'					NOT NULL,
       DTINCLUSAO           DATE            DEFAULT SYSDATE,
       DTULTATU             DATE            DEFAULT SYSDATE,
       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'
)
/
ALTER TABLE FCT_JUSTIFCANCELAAPUR ADD CONSTRAINT PK_FCT_JUSTIFCANCELAAPUR PRIMARY KEY (NRJUSTIFCANCELAAPUR)
/

ALTER TABLE FCT_JUSTIFCANCELAAPUR ADD CONSTRAINT CKC_IDATIVO_FCT_JUSTCANCAP CHECK (IDATIVO IN ('S','N'))
/


ALTER TABLE FCT_CONTRATO ADD NRJUSTIFCANCELAAPUR NUMBER
/

ALTER TABLE FCT_CONTRATO
    ADD CONSTRAINT FKSM00415JUSTCANCAP_CONTRATO FOREIGN KEY (NRJUSTIFCANCELAAPUR)
         REFERENCES FCT_JUSTIFCANCELAAPUR (NRJUSTIFCANCELAAPUR)
/

CREATE INDEX SM00415_FK ON FCT_CONTRATO (NRJUSTIFCANCELAAPUR)
/

ALTER TABLE FCT_FATURACONT ADD NRJUSTIFCANCELAAPUR NUMBER
/
ALTER TABLE FCT_FATURACONT
     ADD CONSTRAINT FKSM00416JUSTCANCAP_FATCONT FOREIGN KEY (NRJUSTIFCANCELAAPUR)
         REFERENCES FCT_JUSTIFCANCELAAPUR (NRJUSTIFCANCELAAPUR)
/

CREATE INDEX SM00416_FK ON FCT_FATURACONT (NRJUSTIFCANCELAAPUR ASC)
/