CREATE TABLE FCM_RELACLOCALCONT (
    NRRELACLOCALCONT        NUMBER      	NOT NULL,
    NRESTRUTURAM            NUMBER       	NOT NULL,
    NRLOCALCLIENTE          NUMBER       	NOT NULL,
    NRSEQCONTRATO           NUMBER       	NOT NULL,
    NRRELACESTRUTCONT       NUMBER       	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',
		CONSTRAINT CKC_IDATIVO_FCM_RELACLOCALCONT CHECK (IDATIVO IN ('S','N'))
)
/

ALTER TABLE FCM_RELACLOCALCONT ADD CONSTRAINT PK_FCM_RELACLOCALCONT PRIMARY KEY (NRRELACLOCALCONT)
/

ALTER TABLE FCM_RELACLOCALCONT 
  ADD CONSTRAINT FKFCM00200RELALOCCONT_ESTRURAM FOREIGN KEY (NRESTRUTURAM)
      REFERENCES ESTRUTURAM (NRESTRUTURAM)
/

CREATE INDEX FCM00200_FK ON FCM_RELACLOCALCONT (NRESTRUTURAM)
/

ALTER TABLE FCM_RELACLOCALCONT 
  ADD CONSTRAINT FKFCM00201RELACLOCCONT_LOCCLI FOREIGN KEY (NRLOCALCLIENTE)
      REFERENCES FCM_LOCALCLI (NRLOCALCLIENTE)
/

CREATE INDEX FCM00201_FK ON FCM_RELACLOCALCONT (NRLOCALCLIENTE)
/   
  
ALTER TABLE FCM_RELACLOCALCONT 
  ADD CONSTRAINT FKFCM00202RELACLOCCONTFCTCONT FOREIGN KEY (NRSEQCONTRATO)
      REFERENCES FCT_CONTRATO (NRSEQCONTRATO)
/

CREATE INDEX FCM00202_FK ON FCM_RELACLOCALCONT (NRSEQCONTRATO)
/
     
ALTER TABLE FCM_RELACLOCALCONT
  ADD CONSTRAINT FKFCM00203RELOCONT_RELTRCONT FOREIGN KEY (NRRELACESTRUTCONT)
      REFERENCES FCT_RELACESTRUTURACONT (NRRELACESTRUTCONT)
/

CREATE INDEX FCM00203_FK ON FCM_RELACLOCALCONT (NRRELACESTRUTCONT)
/