ALTER TABLE FCT_PRECBASESERV ADD NRMOEDA NUMBER
/

ALTER TABLE FCT_PRECBASESERV ADD CONSTRAINT FK_FCT_PRECBASESERV_MOEDA
    FOREIGN KEY (NRMOEDA) REFERENCES FCT_MOEDA (NRMOEDA)
/
CREATE INDEX SM00393_FK ON FCT_PRECBASESERV (NRMOEDA ASC)
/

CREATE TABLE FCT_MODELODOCIDIOMA (
    NRMODELODOCIDIOMA NUMBER 		 NOT NULL,
    NRSEQMODDOCFCT    NUMBER 		 NOT NULL,
    CDIDIOM           VARCHAR2(10),
    NMARQUIVO         VARCHAR2(300),
    DSCAMINHOARQ      VARCHAR2(500),
    DSTIPO            VARCHAR2(150),
    VRTAMANHO         FLOAT(126),
    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 FCT_MODELODOCIDIOMA ADD CONSTRAINT PK_FCT_MODELODOCIDIOMA PRIMARY KEY (NRMODELODOCIDIOMA)
/

ALTER TABLE FCT_MODELODOCIDIOMA ADD CONSTRAINT CKC_IDATIVO_MODDOCIDIOMA CHECK (IDATIVO IN ('S', 'N'))
/

ALTER TABLE FCT_MODELODOCIDIOMA ADD CONSTRAINT FKSM00387MODELODOCIDIOMA_MODOC
    FOREIGN KEY (NRSEQMODDOCFCT) REFERENCES FCT_MODELODOC (NRSEQMODDOCFCT)
/
CREATE INDEX SM00387_FK ON FCT_MODELODOCIDIOMA (NRSEQMODDOCFCT ASC)
/

ALTER TABLE FCT_MODELODOCIDIOMA ADD CONSTRAINT FKSM00388MODELDOCIDIOMA_IDIOMA
    FOREIGN KEY (CDIDIOM) REFERENCES IDIOMA (CDIDIOM)
/
CREATE INDEX SM00388_FK ON FCT_MODELODOCIDIOMA (CDIDIOM ASC)
/

CREATE TABLE FCT_MOEDA (
    NRMOEDA           NUMBER 		 NOT NULL,
    NMMOEDA           VARCHAR2(200)  NOT NULL,
    SIMBOLOMOEDA      VARCHAR2(5),
    CDISOMOEDA        VARCHAR2(3),
    IDPADRAO          VARCHAR2(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'
)
/

ALTER TABLE FCT_MOEDA ADD CONSTRAINT PK_FCT_MOEDA PRIMARY KEY (NRMOEDA)
/

ALTER TABLE FCT_MOEDA ADD CONSTRAINT CKC_IDPADRAO_MOEDA CHECK (IDPADRAO IN ('S', 'N'))
/

ALTER TABLE FCT_MOEDA ADD CONSTRAINT CKC_IDATIVO_MOEDA CHECK (IDATIVO IN ('S', 'N'))
/


ALTER TABLE IDIOMA ADD IDPADRAO VARCHAR2(1) DEFAULT 'N' NOT NULL
/

ALTER TABLE IDIOMA ADD CONSTRAINT CKC_IDPADRAO_IDIOMA CHECK (IDPADRAO IN ('S', 'N'))
/


CREATE TABLE FCT_TABPRECESCOPOFAT (
    NRTABPRECESCOPOFAT  NUMBER  		NOT NULL,
    NRTIPOORCAMENTO     NUMBER 			NOT NULL,
    NRMOEDA             NUMBER,
    CDPRECBASEVEND      VARCHAR2(2),
    CDPRECBASESERV      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'
)
/

ALTER TABLE FCT_TABPRECESCOPOFAT ADD CONSTRAINT PK_FCT_TABPRECESCOPOFAT PRIMARY KEY (NRTABPRECESCOPOFAT)
/

ALTER TABLE FCT_TABPRECESCOPOFAT ADD CONSTRAINT FKSM00389TIPORCATRABPRECESCFAT
    FOREIGN KEY (NRTIPOORCAMENTO) REFERENCES FCT_TIPOORCAMENTO (NRTIPOORCAMENTO)
/
CREATE INDEX SM00389_FK ON FCT_TABPRECESCOPOFAT (NRTIPOORCAMENTO ASC)
/

ALTER TABLE FCT_TABPRECESCOPOFAT ADD CONSTRAINT FKSM00390MOEDATRABPRECESCFAT
    FOREIGN KEY (NRMOEDA) REFERENCES FCT_MOEDA (NRMOEDA)
/
CREATE INDEX SM00390_FK ON FCT_TABPRECESCOPOFAT (NRMOEDA ASC)
/

ALTER TABLE FCT_TABPRECESCOPOFAT ADD CONSTRAINT FKSM00391PRECBASEFCTPRECESCFAT
    FOREIGN KEY (CDPRECBASEVEND) REFERENCES PRECOBASE (CDPRECOBASE)
/
CREATE INDEX SM00391_FK ON FCT_TABPRECESCOPOFAT (CDPRECBASEVEND ASC)
/

ALTER TABLE FCT_TABPRECESCOPOFAT ADD CONSTRAINT FKSM00392PRECBSERVTPRECESCFAT
    FOREIGN KEY (CDPRECBASESERV) REFERENCES FCT_PRECBASESERV (CDPRECBASESERV)
/
CREATE INDEX SM00392_FK ON FCT_TABPRECESCOPOFAT (CDPRECBASESERV ASC)
/

ALTER TABLE FCT_TABPRECESCOPOFAT ADD CONSTRAINT CHK_IDATIVO_FCT_TABPRECESCFAT CHECK (IDATIVO IN ('S', 'N'))
/