ALTER TABLE FCM_LOCALCLI ADD NRESTRUTURAM NUMBER
/
ALTER TABLE FCM_LOCALCLI 
  ADD CONSTRAINT FKSM0381ESTRTURAM_FCM_LOCALCLI FOREIGN KEY (NRESTRUTURAM)
      REFERENCES ESTRUTURAM (NRESTRUTURAM)
/
CREATE INDEX SM00381_FK ON FCM_LOCALCLI (NRESTRUTURAM ASC)
/

ALTER TABLE FCM_CHECKLISTAGEND ADD NRSEQCONTRATO NUMBER
/
ALTER TABLE FCM_CHECKLISTAGEND 
  ADD CONSTRAINT FKSM0382CONTRATO_FCM_CHKAGEND FOREIGN KEY (NRSEQCONTRATO)
      REFERENCES FCT_CONTRATO (NRSEQCONTRATO)
/
CREATE INDEX SM00382_FK ON FCM_CHECKLISTAGEND (NRSEQCONTRATO ASC)
/



ALTER TABLE FCM_GERENCIAMENTOCHK ADD NRSEQCONTRATO NUMBER
/
ALTER TABLE FCM_GERENCIAMENTOCHK 
  ADD CONSTRAINT FKSM0383CONTRATO_FCM_GERCHK FOREIGN KEY (NRSEQCONTRATO)
      REFERENCES FCT_CONTRATO (NRSEQCONTRATO)
/
CREATE INDEX SM00383_FK ON FCM_GERENCIAMENTOCHK (NRSEQCONTRATO ASC)
/

CREATE TABLE FCM_RELSERVITEMTAR (
	NRRELSERVITEMTAR    NUMBER 			NOT NULL,
	CDSERVORCA          NUMBER 			NOT NULL,
	CDTPMEDIDASERV      NUMBER 			NOT NULL,
	NRATIVIDADE         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'
)
/
ALTER TABLE FCM_RELSERVITEMTAR ADD CONSTRAINT PK_FCM_RELSERVITEMTAR PRIMARY KEY (NRRELSERVITEMTAR)
/
ALTER TABLE FCM_RELSERVITEMTAR 
  ADD CONSTRAINT FKSM0384SERVORC_FCM_RELSRVITAR FOREIGN KEY (CDSERVORCA)
      REFERENCES FCT_SERVICOORCA (CDSERVORCA)
/
CREATE INDEX SM00384_FK ON FCM_RELSERVITEMTAR (CDSERVORCA ASC)
/
ALTER TABLE FCM_RELSERVITEMTAR 
  ADD CONSTRAINT FKSM0385TPMEDSRV_FCM_RELSRVITA FOREIGN KEY (CDTPMEDIDASERV)
      REFERENCES FCT_TIPOMEDIDASERV (CDTPMEDIDASERV)
/
CREATE INDEX SM00385_FK ON FCM_RELSERVITEMTAR (CDTPMEDIDASERV ASC)
/
ALTER TABLE FCM_RELSERVITEMTAR 
  ADD CONSTRAINT FKSM0386ATIVIDADE_RELSRVITTAR FOREIGN KEY (NRATIVIDADE)
      REFERENCES FCM_ATIVIDADE (NRATIVIDADE)
/
CREATE INDEX SM00386_FK ON FCM_RELSERVITEMTAR (NRATIVIDADE ASC)
/
ALTER TABLE FCM_RELSERVITEMTAR ADD CONSTRAINT CHK_IDATIVO_FCM_RELSERVITTAR CHECK (IDATIVO IN ('S', 'N'))
/