CREATE TABLE FCM_UNIDADEMEDIDA (
    NRUNIDADEMEDIDA      	NUMBER 			NOT NULL,
    NMUNIDADEMEDIDA      	VARCHAR2 (250) 	NOT NULL,
    NMABREVUNIDADEMEDIDA 	VARCHAR2(3),
    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_UNIDMED CHECK (IDATIVO IN ('S','N'))
)
/

ALTER TABLE FCM_UNIDADEMEDIDA ADD CONSTRAINT PK_FCM_UNIDADEMEDIDA PRIMARY KEY (NRUNIDADEMEDIDA)
/

CREATE TABLE FCM_CATEGORIAMANUT (
    NRCATEGORIAMANUT  		NUMBER 			NOT NULL,
    NMCATEGORIAMANUT  		VARCHAR2 (250) 	NOT NULL,
    NMABREVCATEGMANUT 		VARCHAR2 (250),
    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_CATMANUT CHECK (IDATIVO IN ('S','N'))
)
/

ALTER TABLE FCM_CATEGORIAMANUT ADD CONSTRAINT PK_FCM_CATEGORIAMANUT PRIMARY KEY (NRCATEGORIAMANUT)
/

CREATE TABLE FCM_FUNCCATEGORIAMANUT (
    NRFUNCCATEGORIAMANUT  	NUMBER 			NOT NULL,
    NRCATEGORIAMANUT      	NUMBER 			NOT NULL,
    NRFUNCIONARIO         	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_FCM_FUNCCATMAN CHECK (IDATIVO IN ('S','N'))
)
/

ALTER TABLE FCM_FUNCCATEGORIAMANUT ADD CONSTRAINT PK_FCM_FUNCCATEGORIAMANUT PRIMARY KEY (NRFUNCCATEGORIAMANUT)
/

CREATE INDEX FCM00093_FK ON FCM_FUNCCATEGORIAMANUT (NRFUNCIONARIO ASC)
/

ALTER TABLE FCM_FUNCCATEGORIAMANUT 
  ADD CONSTRAINT FKFCM00093FUNC_FUNCCATMAN FOREIGN KEY (NRFUNCIONARIO)
      REFERENCES FCM_FUNCIONARIO (NRFUNCIONARIO)
/

CREATE TABLE FCM_CATEGORIAEQUIP (
    NRCATEGORIAEQUIP  		NUMBER 			NOT NULL,
    NMCATEGORIAEQUIP  		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',
		CONSTRAINT CKC_IDATIVO_FCM_CATEQUIP CHECK (IDATIVO IN ('S','N'))
)
/

ALTER TABLE FCM_CATEGORIAEQUIP ADD CONSTRAINT PK_FCM_CATEGORIAEQUIP PRIMARY KEY (NRCATEGORIAEQUIP)
/

CREATE TABLE FCM_RELCATEGORIAEQUIPMANUT (
    NRRELCATEGORIAEQUIPMANUT NUMBER 		 NOT NULL,
    NRCATEGORIAEQUIP  		 NUMBER 	 	 NOT NULL,
    NRCATEGORIAMANUT  		 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_RELCATEQUIPMAN CHECK (IDATIVO IN ('S','N'))
)
/

ALTER TABLE FCM_RELCATEGORIAEQUIPMANUT ADD CONSTRAINT PK_FCM_RELCATEGORIAEQUIPMANUT PRIMARY KEY (NRRELCATEGORIAEQUIPMANUT)
/

CREATE INDEX FCM00094_FK ON FCM_RELCATEGORIAEQUIPMANUT (NRCATEGORIAEQUIP ASC)
/

ALTER TABLE FCM_RELCATEGORIAEQUIPMANUT 
  ADD CONSTRAINT FKFCM00094CATEQP_RELCATEQPMAN FOREIGN KEY (NRCATEGORIAEQUIP)
      REFERENCES FCM_CATEGORIAEQUIP (NRCATEGORIAEQUIP)
/

CREATE INDEX FCM00095_FK ON FCM_RELCATEGORIAEQUIPMANUT (NRCATEGORIAMANUT ASC)
/

ALTER TABLE FCM_RELCATEGORIAEQUIPMANUT 
  ADD CONSTRAINT FKFCM00095CATMAN_RELCATEQPMAN FOREIGN KEY (NRCATEGORIAMANUT)
      REFERENCES FCM_CATEGORIAMANUT (NRCATEGORIAMANUT)
/

CREATE TABLE FCM_TIPOMANUTENCAO (
    NRTIPOMANUTENCAO  		NUMBER 			NOT NULL,
    NMTIPOMANUTENCAO  		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',
		CONSTRAINT CKC_IDATIVO_FCM_TPMANUT CHECK (IDATIVO IN ('S','N'))
)
/

ALTER TABLE FCM_TIPOMANUTENCAO ADD CONSTRAINT PK_FCM_TIPOMANUTENCAO PRIMARY KEY (NRTIPOMANUTENCAO)
/

INSERT INTO FCM_TIPOMANUTENCAO (NRTIPOMANUTENCAO, NMTIPOMANUTENCAO, DTINCLUSAO)
      VALUES (1, 'PREDITIVA', SYSDATE)
/

INSERT INTO FCM_TIPOMANUTENCAO (NRTIPOMANUTENCAO, NMTIPOMANUTENCAO, DTINCLUSAO)
      VALUES (2, 'PREVENTIVA', SYSDATE)
/

INSERT INTO FCM_TIPOMANUTENCAO (NRTIPOMANUTENCAO, NMTIPOMANUTENCAO, DTINCLUSAO)
      VALUES (3, 'CORRETIVA', SYSDATE)
/

CREATE TABLE FCM_PRIORIDADEMANUT (
    NRPRIORIDADEMANUT  		NUMBER 			NOT NULL,
    NMPRIORIDADEMANUT  		VARCHAR2 (250) 	NOT NULL,
    DSCORPRIORIDADE    		VARCHAR2 (10),
    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_PRIMANUT CHECK (IDATIVO IN ('S','N'))
)
/

ALTER TABLE FCM_PRIORIDADEMANUT ADD CONSTRAINT PK_FCM_PRIORIDADEMANUT PRIMARY KEY (NRPRIORIDADEMANUT)
/

CREATE TABLE FCM_IMPACTOMANUT (
    NRIMPACTOMANUT         	NUMBER 			NOT NULL,
    NMIMPACTOMANUT         	VARCHAR2 (250) 	NOT NULL,
    NRPRIORIDADEMANUTPADR  	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_FCM_IMPMANUT CHECK (IDATIVO IN ('S','N'))
)
/

ALTER TABLE FCM_IMPACTOMANUT ADD CONSTRAINT PK_FCM_IMPACTOMANUT PRIMARY KEY (NRIMPACTOMANUT)
/

CREATE TABLE FCM_RELPRIORIDADEIMPACTO (
    RELPRIORIDADEIMPACTO   	NUMBER 			NOT NULL,
    NRPRIORIDADEMANUT      	NUMBER 			NOT NULL,
    NRIMPACTOMANUT         	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_RELPRIOIMP CHECK (IDATIVO IN ('S','N'))
)
/

ALTER TABLE FCM_RELPRIORIDADEIMPACTO ADD CONSTRAINT PK_FCM_RELPRIORIDADEIMPACTO PRIMARY KEY (RELPRIORIDADEIMPACTO)
/

CREATE INDEX FCM00096_FK ON FCM_RELPRIORIDADEIMPACTO (NRPRIORIDADEMANUT ASC)
/

ALTER TABLE FCM_RELPRIORIDADEIMPACTO 
  ADD CONSTRAINT FKFCM00096PRIOMAN_RELPRIOIMP FOREIGN KEY (NRPRIORIDADEMANUT)
      REFERENCES FCM_PRIORIDADEMANUT (NRPRIORIDADEMANUT)
/

CREATE INDEX FCM00097_FK ON FCM_RELPRIORIDADEIMPACTO (NRIMPACTOMANUT ASC)
/

ALTER TABLE FCM_RELPRIORIDADEIMPACTO 
  ADD CONSTRAINT FKFCM00097IMPMAN_RELPRIOIMP FOREIGN KEY (NRIMPACTOMANUT)
      REFERENCES FCM_IMPACTOMANUT (NRIMPACTOMANUT)
/

CREATE TABLE FCM_ESCOPOMANUT (
    NRESCOPOMANUT   		NUMBER 			NOT NULL,
    NMESCOPOMANUT   		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',
		CONSTRAINT CKC_IDATIVO_FCM_ESCOPOMANUT CHECK (IDATIVO IN ('S','N'))
)
/

ALTER TABLE FCM_ESCOPOMANUT ADD CONSTRAINT PK_FCM_ESCOPOMANUT PRIMARY KEY (NRESCOPOMANUT)
/

CREATE TABLE FCM_EQUIPAMENTO (
    NREQUIPAMENTO     		NUMBER 			NOT NULL,
    NMEQUIPAMENTO     		VARCHAR2(250) 	NOT NULL,
    CDEQUIPAMENTO     		VARCHAR2(30),
    NRCATEGORIAEQUIP  		NUMBER 			NOT NULL,
    IDSITUACAO        		CHAR(1),
    CDEMPRESA         		VARCHAR2(2),
    CDBEMATIVO        		VARCHAR2(10),
    CDPRODUTO         		VARCHAR2(10),
    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_EQUIP CHECK (IDATIVO IN ('S','N'))
)
/

ALTER TABLE FCM_EQUIPAMENTO ADD CONSTRAINT PK_FCM_EQUIPAMENTO PRIMARY KEY (NREQUIPAMENTO)
/

CREATE INDEX FCM00098_FK ON FCM_EQUIPAMENTO (NRCATEGORIAEQUIP ASC)
/

ALTER TABLE FCM_EQUIPAMENTO 
  ADD CONSTRAINT FKFCM00098CATEQUIP_EQUIPAMEN FOREIGN KEY (NRCATEGORIAEQUIP)
      REFERENCES FCM_CATEGORIAEQUIP (NRCATEGORIAEQUIP)
/

CREATE INDEX FCM00099_FK ON FCM_EQUIPAMENTO (CDEMPRESA ASC, CDBEMATIVO ASC)
/

ALTER TABLE FCM_EQUIPAMENTO 
  ADD CONSTRAINT FKFCM00099EQUIPAMEN_BEMATIVO FOREIGN KEY (CDEMPRESA, CDBEMATIVO)
      REFERENCES BEMATIVO (CDEMPRESA, CDBEMATIVO) ON DELETE CASCADE
/

CREATE INDEX FCM00100_FK ON FCM_EQUIPAMENTO (CDPRODUTO ASC)
/

ALTER TABLE FCM_EQUIPAMENTO 
  ADD CONSTRAINT FKFCM00100EQUIPAMENTO_PRODUTO FOREIGN KEY (CDPRODUTO)
      REFERENCES PRODUTO (CDPRODUTO) ON DELETE CASCADE
/

ALTER TABLE FCM_EQUIPAMENTO ADD CONSTRAINT CKC_IDSITUACAO_FCM_EQUIP CHECK (IDSITUACAO IN ('1','2','3'))
/

CREATE TABLE FCM_RELACESCOPOSEQUIP (
    RELACESCOPOSEQUIP 		NUMBER 			NOT NULL,
    NREQUIPAMENTO     		NUMBER 			NOT NULL,
    NRESCOPOMANUT     		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_RELESCEQUIP CHECK (IDATIVO IN ('S','N'))
)
/

ALTER TABLE FCM_RELACESCOPOSEQUIP ADD CONSTRAINT PK_FCM_RELACESCOPOSEQUIP PRIMARY KEY (RELACESCOPOSEQUIP)
/

CREATE INDEX FCM00101_FK ON FCM_RELACESCOPOSEQUIP (NREQUIPAMENTO ASC)
/

ALTER TABLE FCM_RELACESCOPOSEQUIP 
  ADD CONSTRAINT FKFCM00101EQUIP_RELESCEQUIP FOREIGN KEY (NREQUIPAMENTO)
      REFERENCES FCM_EQUIPAMENTO (NREQUIPAMENTO) ON DELETE CASCADE
/

CREATE INDEX FCM00102_FK ON FCM_RELACESCOPOSEQUIP (NRESCOPOMANUT ASC)
/

ALTER TABLE FCM_RELACESCOPOSEQUIP 
  ADD CONSTRAINT FKFCM00102ESCMAN_RELESCEQUIP FOREIGN KEY (NRESCOPOMANUT)
      REFERENCES FCM_ESCOPOMANUT (NRESCOPOMANUT)
/

CREATE TABLE FCM_IMGEQUIPAMENTO (
    NRIMGEQUIPAMENTO  		NUMBER 			NOT NULL,
    NREQUIPAMENTO     		NUMBER 			NOT NULL,
    DSCAMINHO         		VARCHAR2(4000),
    DSTYPE            		VARCHAR2(100),
    NRSIZE            		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_FCM_IMGEQUIP CHECK (IDATIVO IN ('S','N'))
)
/

ALTER TABLE FCM_IMGEQUIPAMENTO ADD CONSTRAINT PK_FCM_IMGEQUIPAMENTO PRIMARY KEY (NRIMGEQUIPAMENTO)
/

CREATE INDEX FCM00103_FK ON FCM_IMGEQUIPAMENTO (NREQUIPAMENTO ASC)
/

ALTER TABLE FCM_IMGEQUIPAMENTO 
  ADD CONSTRAINT FKFCM00103EQUIPAMEN_IMGEQUIP FOREIGN KEY (NREQUIPAMENTO)
      REFERENCES FCM_EQUIPAMENTO (NREQUIPAMENTO) ON DELETE CASCADE
/

CREATE TABLE FCM_INSUMO (
    NRINSUMO          		NUMBER 			NOT NULL,
    NMINSUMO          		VARCHAR2(250) 	NOT NULL,
    CDINSUMO          		VARCHAR2(30),
    CDPRODUTO         		VARCHAR2(10),
    NRUNIDADEMEDIDA   		NUMBER,
    QTESTOQUE         		NUMBER,
    QTULTIMARETIRADA  		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_FCM_INSUMO CHECK (IDATIVO IN ('S','N'))
)
/

ALTER TABLE FCM_INSUMO ADD CONSTRAINT PK_FCM_INSUMO PRIMARY KEY (NRINSUMO)
/

CREATE INDEX FCM00104_FK ON FCM_INSUMO (CDPRODUTO ASC)
/

ALTER TABLE FCM_INSUMO 
  ADD CONSTRAINT FKFCM00104INSUMO_PRODUTO FOREIGN KEY (CDPRODUTO)
      REFERENCES PRODUTO (CDPRODUTO) ON DELETE CASCADE
/

CREATE INDEX FCM00105_FK ON FCM_INSUMO (NRUNIDADEMEDIDA ASC)
/

ALTER TABLE FCM_INSUMO 
  ADD CONSTRAINT FKFCM00105INSUMO_UNIDMEDIDA FOREIGN KEY (NRUNIDADEMEDIDA)
      REFERENCES FCM_UNIDADEMEDIDA (NRUNIDADEMEDIDA)
/

CREATE TABLE FCM_IMGINSUMO (
    NRIMGINSUMO       		NUMBER 			NOT NULL,
    NRINSUMO          		NUMBER 			NOT NULL,
    DSCAMINHO         		VARCHAR2(4000),
    DSTYPE            		VARCHAR2(100),
    NRSIZE            		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_FCM_IMGINSUMO CHECK (IDATIVO IN ('S','N'))
)
/

ALTER TABLE FCM_IMGINSUMO ADD CONSTRAINT PK_FCM_IMGINSUMO PRIMARY KEY (NRIMGINSUMO)
/

CREATE INDEX FCM00106_FK ON FCM_IMGINSUMO (NRINSUMO ASC)
/

ALTER TABLE FCM_IMGINSUMO 
  ADD CONSTRAINT FKFCM00106IMGINSUMO_INSUMO FOREIGN KEY (NRINSUMO)
      REFERENCES FCM_INSUMO (NRINSUMO) ON DELETE CASCADE
/

CREATE TABLE FCM_RELINSUMOSEQUIP (
    NRRELINSUMOSEQUIP 		NUMBER 			NOT NULL,
    NREQUIPAMENTO     		NUMBER 			NOT NULL,
    NRINSUMO          		NUMBER 			NOT NULL,
    NRTIPOMANUTENCAO  		NUMBER 			NOT NULL,
    NRCATEGORIAMANUT  		NUMBER,
    QTMEDIDA          		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_FCM_INSUMEQUIP CHECK (IDATIVO IN ('S','N'))
)
/

ALTER TABLE FCM_RELINSUMOSEQUIP ADD CONSTRAINT PK_FCM_RELINSUMOSEQUIP PRIMARY KEY (NRINSUMOSEQUIP  )
/

CREATE INDEX FCM00107_FK ON FCM_RELINSUMOSEQUIP (NREQUIPAMENTO ASC)
/

ALTER TABLE FCM_RELINSUMOSEQUIP 
  ADD CONSTRAINT FKFCM00107EQUIPAM_INSUMEQUIP FOREIGN KEY (NREQUIPAMENTO)
      REFERENCES FCM_EQUIPAMENTO (NREQUIPAMENTO) ON DELETE CASCADE
/

CREATE INDEX FCM00108_FK ON FCM_RELINSUMOSEQUIP (NRINSUMO ASC)
/

ALTER TABLE FCM_RELINSUMOSEQUIP 
  ADD CONSTRAINT FKFCM00108INSUMEQUIP_INSUMO FOREIGN KEY (NRINSUMO)
      REFERENCES FCM_INSUMO (NRINSUMO) ON DELETE CASCADE
/

CREATE INDEX FCM00109_FK ON FCM_RELINSUMOSEQUIP (NRTIPOMANUTENCAO ASC)
/

ALTER TABLE FCM_RELINSUMOSEQUIP 
  ADD CONSTRAINT FKFCM00109INSUMEQUIP_TPMANUT FOREIGN KEY (NRTIPOMANUTENCAO)
      REFERENCES FCM_TIPOMANUTENCAO (NRTIPOMANUTENCAO)
/

CREATE INDEX FCM00110_FK ON FCM_RELINSUMOSEQUIP (NRCATEGORIAMANUT ASC)
/
      
ALTER TABLE FCM_RELINSUMOSEQUIP 
  ADD CONSTRAINT FKFCM00110INSUMEQUIP_CATMANUT FOREIGN KEY (NRCATEGORIAMANUT)
      REFERENCES FCM_CATEGORIAMANUT (NRCATEGORIAMANUT)
/

CREATE TABLE FCM_SOLICITACAOSERV (
    NRSOLICITACAOSERV  		NUMBER 			NOT NULL,
    NMSOLICITACAOSERV  		VARCHAR2(250),
    DTSOLICITACAOSERV  		DATE 			NOT NULL,
    NRFUNCSOLICITANTE  		NUMBER 			NOT NULL,
    IDSITUACAO         		CHAR(1) 		DEFAULT '1' NOT NULL,
    NREQUIPAMENTO      		NUMBER 			NOT NULL,
    NRCATEGORIAMANUT   		NUMBER,
    NRIMPACTOMANUT     		NUMBER,
    NRPRIORIDADEMANUT  		NUMBER,
    DSSOLICITACAOSERV  		VARCHAR2 (4000),
    NRESCOPOMANUT      		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_FCM_SOLICSERV CHECK (IDATIVO IN ('S','N'))
)
/

ALTER TABLE FCM_SOLICITACAOSERV ADD CONSTRAINT PK_FCM_SOLICITACAOSERV PRIMARY KEY (NRSOLICITACAOSERV)
/

CREATE INDEX FCM00111_FK ON FCM_SOLICITACAOSERV (NRFUNCSOLICITANTE ASC)
/

ALTER TABLE FCM_SOLICITACAOSERV 
  ADD CONSTRAINT FKFCM00111SOLICSERV_FUNC FOREIGN KEY (NRFUNCSOLICITANTE)
      REFERENCES FCM_FUNCIONARIO (NRFUNCIONARIO)
/

CREATE INDEX FCM00112_FK ON FCM_SOLICITACAOSERV (NREQUIPAMENTO ASC)
/

ALTER TABLE FCM_SOLICITACAOSERV 
  ADD CONSTRAINT FKFCM00112SOLICSERV_EQUIP FOREIGN KEY (NREQUIPAMENTO)
      REFERENCES FCM_EQUIPAMENTO (NREQUIPAMENTO)
/

CREATE INDEX FCM00113_FK ON FCM_SOLICITACAOSERV (NRCATEGORIAMANUT ASC)
/

ALTER TABLE FCM_SOLICITACAOSERV 
  ADD CONSTRAINT FKFCM00113SOLICSERV_CATMANUT FOREIGN KEY (NRCATEGORIAMANUT)
      REFERENCES FCM_CATEGORIAMANUT (NRCATEGORIAMANUT)
/

CREATE INDEX FCM00114_FK ON FCM_SOLICITACAOSERV (NRIMPACTOMANUT ASC)
/

ALTER TABLE FCM_SOLICITACAOSERV 
  ADD CONSTRAINT FKFCM00114SOLICSERV_IMPMANUT  FOREIGN KEY (NRIMPACTOMANUT)
      REFERENCES FCM_IMPACTOMANUT (NRIMPACTOMANUT)
/

CREATE INDEX FCM00115_FK ON FCM_SOLICITACAOSERV (NRPRIORIDADEMANUT ASC)
/

ALTER TABLE FCM_SOLICITACAOSERV 
  ADD CONSTRAINT FKFCM00115SOLICSERV_PRIOMANUT  FOREIGN KEY (NRPRIORIDADEMANUT)
      REFERENCES FCM_PRIORIDADEMANUT (NRPRIORIDADEMANUT)
/

CREATE INDEX FCM00116_FK ON FCM_SOLICITACAOSERV (NRESCOPOMANUT ASC)
/

ALTER TABLE FCM_SOLICITACAOSERV 
  ADD CONSTRAINT FKFCM00116SOLICSERV_ESCOPMANUT FOREIGN KEY (NRESCOPOMANUT)
      REFERENCES FCM_ESCOPOMANUT (NRESCOPOMANUT)
/

ALTER TABLE FCM_SOLICITACAOSERV ADD CONSTRAINT CKC_IDSITUACAO_FCM_SOLICSERV CHECK (IDSITUACAO IN ('1', '2', '3', '4'))
/

CREATE TABLE FCM_IMGSOLICITACAOSERV (
    NRIMGSOLICITACAOSERV  	NUMBER 			NOT NULL,
    NRSOLICITACAOSERV     	NUMBER 			NOT NULL,
    DSCAMINHO             	VARCHAR2(4000),
    DSTYPE                	VARCHAR2(100),
    NRSIZE                	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_FCM_IMGSOLICSERV CHECK (IDATIVO IN ('S','N'))
)
/

ALTER TABLE FCM_IMGSOLICITACAOSERV ADD CONSTRAINT PK_FCM_IMGSOLICITACAOSERV PRIMARY KEY (NRIMGSOLICITACAOSERV)
/

CREATE INDEX FCM00117_FK ON FCM_IMGSOLICITACAOSERV (NRSOLICITACAOSERV ASC)
/

ALTER TABLE FCM_IMGSOLICITACAOSERV 
  ADD CONSTRAINT FKFCM00117IMGSOLSERV_SOLCSERV FOREIGN KEY (NRSOLICITACAOSERV)
      REFERENCES FCM_SOLICITACAOSERV (NRSOLICITACAOSERV) ON DELETE CASCADE
/

CREATE TABLE FCM_COMENTSOLICITSERV (
    NRCOMENTSOLICITSERV  	NUMBER 			NOT NULL,
    NRSOLICITACAOSERV    	NUMBER 			NOT NULL,
    NRFUNCCOMENTARIO     	NUMBER 			NOT NULL,
    DTCOMENTARIO         	DATE,
    DSCOMENTARIO         	VARCHAR2(4000),
    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_COMSOLICSERV CHECK (IDATIVO IN ('S','N'))
)
/

ALTER TABLE FCM_COMENTSOLICITSERV ADD CONSTRAINT PK_FCM_COMENTSOLICITSERV PRIMARY KEY (NRCOMENTSOLICITSERV)
/

CREATE INDEX FCM00118_FK ON FCM_COMENTSOLICITSERV (NRSOLICITACAOSERV ASC)
/

ALTER TABLE FCM_COMENTSOLICITSERV 
  ADD CONSTRAINT FKFCM00118COMSOLSERV_SOLSERV FOREIGN KEY (NRSOLICITACAOSERV)
      REFERENCES FCM_SOLICITACAOSERV (NRSOLICITACAOSERV) ON DELETE CASCADE
/

CREATE INDEX FCM00119_FK ON FCM_COMENTSOLICITSERV (NRFUNCCOMENTARIO ASC)
/

ALTER TABLE FCM_COMENTSOLICITSERV 
  ADD CONSTRAINT FKFCM00119COMSOLICSERV_FUNC FOREIGN KEY (NRFUNCCOMENTARIO)
      REFERENCES FCM_FUNCIONARIO (NRFUNCIONARIO)
/

CREATE TABLE FCM_RELESCSOLICITASERV (
    NRRELESCSOLICITASERV  	NUMBER 			NOT NULL,
    NRSOLICITACAOSERV     	NUMBER 			NOT NULL,
    NRESCOPOMANUT         	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_RELESCSOL CHECK (IDATIVO IN ('S','N'))
)
/

ALTER TABLE FCM_RELESCSOLICITASERV ADD CONSTRAINT PK_FCM_RELESCSOLICITASERV PRIMARY KEY (NRRELESCSOLICITASERV)
/

CREATE INDEX FCM00120_FK ON FCM_RELESCSOLICITASERV (NRSOLICITACAOSERV ASC)
/

ALTER TABLE FCM_RELESCSOLICITASERV 
  ADD CONSTRAINT FKFCM00120RELESCSOL_SOLICSERV FOREIGN KEY (NRSOLICITACAOSERV)
      REFERENCES FCM_SOLICITACAOSERV (NRSOLICITACAOSERV) ON DELETE CASCADE
/

CREATE INDEX FCM00121_FK ON FCM_RELESCSOLICITASERV (NRESCOPOMANUT ASC)
/

ALTER TABLE FCM_RELESCSOLICITASERV 
  ADD CONSTRAINT FKFCM00121RELESCSOL_ESCOPMANUT FOREIGN KEY (NRESCOPOMANUT)
      REFERENCES FCM_ESCOPOMANUT (NRESCOPOMANUT)
/

CREATE TABLE FCM_ORDEMSERV (
    NRORDEMSERV        		NUMBER 			NOT NULL,
    NMORDEMOSERV       		VARCHAR2(250),
    DTORDEMSERV        		DATE 			NOT NULL,
    IDSITUACAO         		CHAR(1) 		DEFAULT '1' NOT NULL,
    NREQUIPAMENTO      		NUMBER 			NOT NULL,
    NRCATEGORIAMANUT   		NUMBER,
    NRTIPOMANUTENCAO   		NUMBER,
    NRPRIORIDADEMANUT  		NUMBER,
    DSORDEMSERV        		VARCHAR2 (4000),
    IDFUNCEXTERNO      		CHAR(1) 		DEFAULT 'N' 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_ORDEMSERV CHECK (IDATIVO IN ('S','N'))
)
/

ALTER TABLE FCM_ORDEMSERV ADD CONSTRAINT PK_FCM_ORDEMSERV PRIMARY KEY (NRORDEMSERV)
/

CREATE INDEX FCM00122_FK ON FCM_ORDEMSERV (NREQUIPAMENTO ASC)
/

ALTER TABLE FCM_ORDEMSERV 
  ADD CONSTRAINT FKFCM00122ORDEMSERV_EQUIP FOREIGN KEY (NREQUIPAMENTO)
      REFERENCES FCM_EQUIPAMENTO (NREQUIPAMENTO)
/

CREATE INDEX FCM00123_FK ON FCM_ORDEMSERV (NRCATEGORIAMANUT ASC)
/

ALTER TABLE FCM_ORDEMSERV 
  ADD CONSTRAINT FKFCM00123ORDEMSERV_CATMANUT  FOREIGN KEY (NRCATEGORIAMANUT)
      REFERENCES FCM_CATEGORIAMANUT (NRCATEGORIAMANUT)
/

CREATE INDEX FCM00124_FK ON FCM_ORDEMSERV (NRTIPOMANUTENCAO ASC)
/

ALTER TABLE FCM_ORDEMSERV 
  ADD CONSTRAINT FKFCM00124ORDEMSERV_TIPOMANUT  FOREIGN KEY (NRTIPOMANUTENCAO)
      REFERENCES FCM_TIPOMANUTENCAO (NRTIPOMANUTENCAO)
/

CREATE INDEX FCM00125_FK ON FCM_ORDEMSERV (NRPRIORIDADEMANUT ASC)
/

ALTER TABLE FCM_ORDEMSERV 
  ADD CONSTRAINT FKFCM00125ORDEMSERV_PRIOMANUT FOREIGN KEY (NRPRIORIDADEMANUT)
      REFERENCES FCM_PRIORIDADEMANUT (NRPRIORIDADEMANUT)
/

ALTER TABLE FCM_ORDEMSERV ADD CONSTRAINT CKC_IDSITUACAO_FCM_ORDEMSERV CHECK (IDSITUACAO IN ('1', '2', '3'))
/

ALTER TABLE FCM_ORDEMSERV ADD CONSTRAINT CKC_IDFUNCEXTERN_FCM_ORDEMSERV CHECK (IDFUNCEXTERNO IN ('S', 'N'))
/

CREATE TABLE FCM_IMGORDEMSERV (
    NRIMGORDEMSERV  		NUMBER 			NOT NULL,
    NRORDEMSERV     		NUMBER 			NOT NULL,
    DSCAMINHO       		VARCHAR2(4000),
    DSTYPE          		VARCHAR2(100),
    NRSIZE          		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_FCM_IMGORDEMSERV CHECK (IDATIVO IN ('S','N'))
)
/

ALTER TABLE FCM_IMGORDEMSERV ADD CONSTRAINT PK_FCM_IMGORDEMSERV PRIMARY KEY (NRIMGORDEMSERV)
/

CREATE INDEX FCM00126_FK ON FCM_IMGORDEMSERV (NRORDEMSERV ASC)
/

ALTER TABLE FCM_IMGORDEMSERV 
  ADD CONSTRAINT FKFCM00126IMGORDSERV_ORDSERV FOREIGN KEY (NRORDEMSERV)
      REFERENCES FCM_ORDEMSERV (NRORDEMSERV) ON DELETE CASCADE
/

CREATE TABLE FCM_COMENTORDEMSERV (
    NRCOMENTORDEMSERV    	NUMBER 			NOT NULL,
    NRORDEMSERV          	NUMBER 			NOT NULL,
    NRFUNCCOMENTARIO     	NUMBER 			NOT NULL,
    DTCOMENTARIO         	DATE,
    DSCOMENTARIO         	VARCHAR2(4000),
    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_COMORDEMSERV CHECK (IDATIVO IN ('S','N'))
)
/

ALTER TABLE FCM_COMENTORDEMSERV ADD CONSTRAINT PK_FCM_COMENTORDEMSERV PRIMARY KEY (NRCOMENTORDEMSERV)
/

CREATE INDEX FCM00127_FK ON FCM_COMENTORDEMSERV (NRORDEMSERV ASC)
/

ALTER TABLE FCM_COMENTORDEMSERV 
  ADD CONSTRAINT FKFCM00127ORDSERV_COMORDSERV FOREIGN KEY (NRORDEMSERV)
      REFERENCES FCM_ORDEMSERV (NRORDEMSERV) ON DELETE CASCADE
/

CREATE INDEX FCM00128_FK ON FCM_COMENTORDEMSERV (NRFUNCCOMENTARIO ASC)
/

ALTER TABLE FCM_COMENTORDEMSERV 
  ADD CONSTRAINT FKFCM00128COMORDSERV_FUNC FOREIGN KEY (NRFUNCCOMENTARIO)
      REFERENCES FCM_FUNCIONARIO (NRFUNCIONARIO)
/

CREATE TABLE FCM_RESPONSAVEISORDEMSERV (
    NRRESPONSAVEISORDEMSERV  NUMBER 		NOT NULL,
    NRORDEMSERV              NUMBER 		NOT NULL,
    NRFUNCIONARIO            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_RESPORDEMSERV CHECK (IDATIVO IN ('S','N'))
)
/

ALTER TABLE FCM_RESPONSAVEISORDEMSERV ADD CONSTRAINT PK_FCM_RESPONSAVEISORDEMSERV PRIMARY KEY (NRRESPONSAVEISORDEMSERV)
/

CREATE INDEX FCM00129_FK ON FCM_RESPONSAVEISORDEMSERV (NRORDEMSERV ASC)
/

ALTER TABLE FCM_RESPONSAVEISORDEMSERV 
  ADD CONSTRAINT FKFCM00129RESPORDSERV_ORDSERV FOREIGN KEY (NRORDEMSERV)
      REFERENCES FCM_ORDEMSERV (NRORDEMSERV) ON DELETE CASCADE
/

CREATE INDEX FCM00130_FK ON FCM_RESPONSAVEISORDEMSERV (NRFUNCIONARIO ASC)
/

ALTER TABLE FCM_RESPONSAVEISORDEMSERV 
  ADD CONSTRAINT FKFCM00130RESPORDSERV_FUNC FOREIGN KEY (NRFUNCIONARIO)
      REFERENCES FCM_FUNCIONARIO (NRFUNCIONARIO)
/

CREATE TABLE FCM_RELESCORDEMSERV (
    NRRELESCORDEMSERV  		NUMBER 			NOT NULL,
    NRORDEMSERV        		NUMBER 			NOT NULL,
    NRESCOPOMANUT      		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_RELESCORDSERV CHECK (IDATIVO IN ('S','N'))
)
/

ALTER TABLE FCM_RELESCORDEMSERV ADD CONSTRAINT PK_FCM_RELESCORDEMSERV PRIMARY KEY (NRRELESCORDEMSERV)
/

CREATE INDEX FCM00131_FK ON FCM_RELESCORDEMSERV (NRORDEMSERV ASC)
/

ALTER TABLE FCM_RELESCORDEMSERV 
  ADD CONSTRAINT FKFCM00131RELESCORD_SOLICSERV FOREIGN KEY (NRORDEMSERV)
      REFERENCES FCM_ORDEMSERV (NRORDEMSERV) ON DELETE CASCADE
/

CREATE INDEX FCM00132_FK ON FCM_RELESCORDEMSERV (NRESCOPOMANUT ASC)
/

ALTER TABLE FCM_RELESCORDEMSERV 
  ADD CONSTRAINT FKFCM00132RELESCORD_ESCMANUT FOREIGN KEY (NRESCOPOMANUT)
      REFERENCES FCM_ESCOPOMANUT (NRESCOPOMANUT)
/

CREATE TABLE FCM_RELSOLICITAORDEMSERV (
    NRRELSOLICITAORDEMSERV  NUMBER 			NOT NULL,
    NRSOLICITACAOSERV       NUMBER 			NOT NULL,
    NRORDEMSERV             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_RELSOLORDSERV CHECK (IDATIVO IN ('S','N'))
)
/

ALTER TABLE FCM_RELSOLICITAORDEMSERV ADD CONSTRAINT PK_FCM_RELSOLICITAORDEMSERV PRIMARY KEY (NRRELSOLICITAORDEMSERV)
/

CREATE INDEX FCM00133_FK ON FCM_RELSOLICITAORDEMSERV (NRSOLICITACAOSERV ASC)
/

ALTER TABLE FCM_RELSOLICITAORDEMSERV 
  ADD CONSTRAINT FKFCM00133RELSOLORD_SOLSERV FOREIGN KEY (NRSOLICITACAOSERV)
      REFERENCES FCM_SOLICITACAOSERV (NRSOLICITACAOSERV)
/

CREATE INDEX FCM00134_FK ON FCM_RELSOLICITAORDEMSERV (NRORDEMSERV ASC)
/

ALTER TABLE FCM_RELSOLICITAORDEMSERV 
  ADD CONSTRAINT FKFCM00134RELSOLORD_ORDSERV FOREIGN KEY (NRORDEMSERV)
      REFERENCES FCM_ORDEMSERV (NRORDEMSERV) ON DELETE CASCADE
/