CREATE TABLE FCT_RELACCONTRCENTCUST (
	NRRELCONTRCENTCUST     NUMBER NOT NULL,
	NRSEQCONTRATO          NUMBER NOT NULL,
	CDCENTCUST             VARCHAR2(4) NOT NULL,
	VRPERCENTUALCONTCCUST  NUMBER,
	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',
		CONSTRAINT CKC_IDATIVO_FCT_RELACNTRCNTCST CHECK (IDATIVO IN ('S','N'))
)
/

ALTER TABLE FCT_RELACCONTRCENTCUST ADD CONSTRAINT PK_FCT_RELACCONTRCENTCUST PRIMARY KEY (NRRELCONTRCENTCUST)
/

ALTER TABLE FCT_RELACCONTRCENTCUST 
  ADD CONSTRAINT FKSM00445FCT_CONTRT_RELCONTCST FOREIGN KEY (NRSEQCONTRATO)
     REFERENCES FCT_CONTRATO (NRSEQCONTRATO) ON DELETE CASCADE
/

CREATE INDEX SM00445_FK ON FCT_RELACCONTRCENTCUST (NRSEQCONTRATO ASC)
/
ALTER TABLE FCT_RELACCONTRCENTCUST 
  ADD CONSTRAINT FKSM00446CNTCST_FCT_RELCONTCST FOREIGN KEY (CDCENTCUST)
     REFERENCES CENTCUST (CDCENTCUST)
/

CREATE INDEX SM00446_FK ON FCT_RELACCONTRCENTCUST (CDCENTCUST ASC)
/