ALTER TABLE FCT_RELACFORMACAOPROP DROP CONSTRAINT FK_FCT_ITEMORCA_RELFORMPROP 
/
ALTER TABLE FCT_RELACSERVORCAMENTO DROP CONSTRAINT CK_AJUSTE_RELACSERVORCA 
/
ALTER TABLE FCT_RELACSERVORCAMENTO ADD CONSTRAINT CK_AJUSTE_RELACSERVORCA
  CHECK(IDTPDESCORCA IN('V', 'P', 'N', 'X', 'Y'))
/
ALTER TABLE FCT_CALCFORMPRECSERV_ITPRO ADD NRRELACFORMACAOPROP NUMBER
/
ALTER TABLE FCT_DESPESA MODIFY CDPERIODO NULL
/
ALTER TABLE FCT_DESPESA MODIFY CDPERIODO DEFAULT 4
/
ALTER TABLE FCT_RELACDESPPROPOSTA ADD CDPERIODODESPPROP VARCHAR2(1) DEFAULT 4
/
ALTER TABLE FCT_RELACDESPPROPOSTA ADD CONSTRAINT CKC_DESPESAPROP_PERIODO
  CHECK(CDPERIODODESPPROP IN ('1', '2', '3', '4', '5', '6', '7'))
/
ALTER TABLE FCT_RELACINVESTPROPOSTA ADD VRPARCELA FLOAT(126)
/
ALTER TABLE FCT_RELACINVESTPROPOSTA ADD QTMESARMOTIZACAO NUMBER DEFAULT 1
/
ALTER TABLE FCT_RELACSERVORCAMENTO ADD HRENTRADA VARCHAR2(6)
/
ALTER TABLE FCT_RELACSERVORCAMENTO ADD HRSAIDA VARCHAR2(6)
/
CREATE TABLE FCT_RELACIMPOSTOORCA(
  NRIMPOSTOORCA  NUMBER NOT NULL,
  NRSEQORCAMENTO  NUMBER,
  CDIMPOSTO      VARCHAR2(2) NOT NULL,
  VRPERCIMPOSTO  FLOAT(126),
   NRORG                       NUMBER DEFAULT 	 SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
   IDATIVO                    VARCHAR2(1)     DEFAULT 'S' NOT NULL
	CONSTRAINT CKC_IDATIVO_FCT_RELIMPORCA CHECK (IDATIVO IN ('S','N')),
   DTINCLUSAO             DATE                   NULL,
   DTULTATU                  DATE                  NULL,
   NRORGINCLUSAO      NUMBER             DEFAULT 1 NULL,
   CDOPERINCLUSAO    VARCHAR2(12)  DEFAULT '1' NULL,
   NRORGULTATU          NUMBER             DEFAULT 1 NULL,
   CDOPERULTATU        VARCHAR2(12)  DEFAULT '1',
	CONSTRAINT CKC_IDATIVO_RELACIMPOSTORCA CHECK (IDATIVO IN ('S','N'))
)
/
ALTER TABLE FCT_RELACIMPOSTOORCA ADD CONSTRAINT PK_IPTSERV_RELACIMPOSTORCA PRIMARY KEY (NRIMPOSTOORCA)
/
ALTER TABLE FCT_RELACIMPOSTOORCA ADD 
	CONSTRAINT FKSM00184FCT_ORCAMENTO FOREIGN KEY(NRSEQORCAMENTO) 
		REFERENCES FCT_ORCAMENTO(NRSEQORCAMENTO)
/
ALTER TABLE FCT_RELACIMPOSTOORCA ADD 
	CONSTRAINT  FKSM00185IMPOSTO FOREIGN KEY(CDIMPOSTO) 
		REFERENCES IMPOSTO(CDIMPOSTO)
/
ALTER TABLE FCT_RELACFORMACAOPROP ADD QTFORMACAOPROP NUMBER DEFAULT 1
/
ALTER TABLE FCT_ORCAMENTO ADD VRPERCMARKUPAPLICADO NUMBER
/
CREATE TABLE FCT_RESULTORCALIMENT(
  NRRESULTORCA      NUMBER NOT NULL,
  NRSEQORCAMENTO    NUMBER NOT NULL,
  VRCUSTOINFORMADO  FLOAT(126),
  VRCUSTOIDEAL      FLOAT(126),
  IDELEMENTORAIZ    VARCHAR2(100),
  NRCOMPSERVICORAIZ NUMBER,
  QTTOTALSERV       NUMBER,
  VRTOTSERV         FLOAT(126),
   NRORG                       NUMBER DEFAULT 	 SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
   IDATIVO                    VARCHAR2(1)     DEFAULT 'S' NOT NULL
	CONSTRAINT CKC_IDATIVO_FCT_RESORCALI CHECK (IDATIVO IN ('S','N')),
   DTINCLUSAO             DATE                   NULL,
   DTULTATU                  DATE                  NULL,
   NRORGINCLUSAO      NUMBER             DEFAULT 1 NULL,
   CDOPERINCLUSAO    VARCHAR2(12)  DEFAULT '1' NULL,
   NRORGULTATU          NUMBER             DEFAULT 1 NULL,
   CDOPERULTATU        VARCHAR2(12)  DEFAULT '1',
	CONSTRAINT CKC_IDATIVO_RESULTPROP CHECK (IDATIVO IN ('S','N'))
)
/
ALTER TABLE FCT_RESULTORCALIMENT ADD CONSTRAINT PK_RORCA_RESULTPROP PRIMARY KEY (NRRESULTORCA)
/
ALTER TABLE FCT_RESULTORCALIMENT ADD 
	CONSTRAINT  FKSM00186FCT_ORCAMENTO FOREIGN KEY(NRSEQORCAMENTO) 
		REFERENCES FCT_ORCAMENTO(NRSEQORCAMENTO)
/
ALTER TABLE FCT_RESULTORCALIMENT ADD 
	CONSTRAINT FKSM00187FCT_COMPSERVICO FOREIGN KEY(NRCOMPSERVICORAIZ) 
		REFERENCES FCT_COMPSERVICO(NRCOMPSERVICO)