CREATE TABLE GER_GERANFSE (
  NRGERANFSE NUMBER(10) NOT NULL, 
  DSGERANFSE VARCHAR2(100) NOT NULL, 
  DSNOMEARQUIVO VARCHAR2(100) NOT NULL, 
  CDPAIS VARCHAR2(4) DEFAULT '0055' NOT NULL, 
  SGESTADO VARCHAR2(2) NOT NULL,  
  CDMUNICIPIO VARCHAR2(4) NOT NULL, 
  DSCAMINHOGERACAO VARCHAR2(200) NOT NULL, 
  DSVARIAVEIS CLOB DEFAULT NULL NULL, 
  DSDEPENDENCIAS CLOB DEFAULT NULL NULL, 
  DSURLPRODUCAO VARCHAR2(300) NOT NULL, 
  DSURLHOMOLOGACAO VARCHAR2(300) DEFAULT NULL NULL, 
  NRORG NUMBER(10) DEFAULT 1 NULL, 
  IDATIVO VARCHAR2(1) DEFAULT 'S' NULL, 
  DTINCLUSAO DATE DEFAULT SYSDATE NOT NULL, 
  DTULTATU DATE DEFAULT NULL NULL, 
  NRORGINCLUSAO NUMBER(10) DEFAULT 1 NULL, 
  CDOPERINCLUSAO VARCHAR2(12) DEFAULT '1' NOT NULL, 
  NRORGULTATU NUMBER(10) NOT NULL, 
  CDOPERULTATU VARCHAR2(12) NOT NULL,
  CONSTRAINT PK_GER_GERANFSE PRIMARY KEY(NRORG, NRGERANFSE)
)
/
ALTER TABLE GER_GERANFSE ADD CONSTRAINT FKFIS00582PAIS FOREIGN KEY (CDPAIS) REFERENCES PAIS (CDPAIS)
/
ALTER TABLE GER_GERANFSE ADD CONSTRAINT FKFIS00583ESTADO FOREIGN KEY (CDPAIS, SGESTADO) REFERENCES ESTADO (CDPAIS, SGESTADO)
/
ALTER TABLE GER_GERANFSE ADD CONSTRAINT FKFIS00584MUNICIPIO FOREIGN KEY (CDPAIS, SGESTADO, CDMUNICIPIO) REFERENCES MUNICIPIO (CDPAIS, SGESTADO, CDMUNICIPIO)
/
ALTER TABLE GER_GERANFSE ADD CONSTRAINT CKC_IDATIVO_GER_GERANFSE CHECK ((IDATIVO IN ('N', 'S')))
/
CREATE TABLE GER_GERAFUNCOESNFSE (
  NRGERAFUNCOESNFSE NUMBER(10) NOT NULL, 
  NRGERANFSE NUMBER(10) NOT NULL, 
  DSGERAFUNCOESNFSE VARCHAR2(100) DEFAULT NULL NULL, 
  NRORDENACAO NUMBER(10) NOT NULL, 
  NMFUNCAONFSE VARCHAR2(100) NOT NULL, 
  IDTIPOFUNCAONFSE VARCHAR2(10) NOT NULL, 
  DSPARAMFUNCAO VARCHAR2(200) DEFAULT NULL NULL, 
  DSCORPOFUNCAO CLOB NOT NULL, 
  NRORG NUMBER(10) DEFAULT 1 NOT NULL, 
  IDATIVO VARCHAR2(1) DEFAULT 'S' NOT NULL, 
  DTINCLUSAO DATE DEFAULT SYSDATE NOT NULL, 
  DTULTATU DATE NOT NULL, 
  NRORGINCLUSAO NUMBER(10) DEFAULT 1 NULL, 
  CDOPERINCLUSAO VARCHAR2(12) DEFAULT '1' NOT NULL, 
  NRORGULTATU NUMBER(10) DEFAULT NULL NULL, 
  CDOPERULTATU VARCHAR2(12) DEFAULT NULL NULL,
  CONSTRAINT PK_GER_GERAFUNCOESNFSE PRIMARY KEY(DSGERAFUNCOESNFSE)
)
/
ALTER TABLE GER_GERAFUNCOESNFSE ADD CONSTRAINT FKFIS00585GER_GERANFSE FOREIGN KEY (NRGERANFSE) REFERENCES GER_GERANFSE (NRGERANFSE)
/
ALTER TABLE GER_GERAFUNCOESNFSE ADD CONSTRAINT CKC_IDATIVO_GER_GERAFUNCNFSE CHECK ((IDATIVO IN ('N', 'S')))
/
ALTER TABLE GER_GERAFUNCOESNFSE ADD CONSTRAINT CKC_IDTIPOFUNCAONFSE CHECK ((IDTIPOFUNCAONFSE IN ('private', 'public')))
/
ALTER TABLE ARQXMLNFE ADD (
  DSARQXMLNFSE CLOB DEFAULT NULL NULL
)
/
CREATE TABLE PARAMNFSEINSCMUNI (
  NRPARAMNFSEINSCMUNI NUMBER(10) NOT NULL, 
  CDEMPRESA VARCHAR2(2) NOT NULL, 
  CDINSCMUNI VARCHAR2(16) NOT NULL, 
  IDAMBIENTE VARCHAR2(1) NOT NULL, 
  IDLOCALSERVIDOR VARCHAR2(1) NOT NULL, 
  CDSENHACERTDIG VARCHAR2(100) DEFAULT NULL NULL, 
  DSCAMINHOMODELO VARCHAR2(200) DEFAULT NULL NULL, 
  CDSENHAACESSOWS VARCHAR2(100) DEFAULT NULL NULL, 
  IDATIVO VARCHAR2(1) DEFAULT 'S' NOT NULL, 
  NRORG NUMBER(10) NOT NULL, 
  DTINCLUSAO DATE DEFAULT SYSDATE NOT NULL, 
  NRORGINCLUSAO NUMBER(10) NOT NULL, 
  CDOPERINCLUSAO VARCHAR2(12) NOT NULL, 
  DTULTATU DATE DEFAULT NULL NULL, 
  NRORGULTATU NUMBER(10) DEFAULT NULL NULL, 
  CDOPERULTATU VARCHAR2(12) DEFAULT NULL NULL,
  CONSTRAINT PK_PARAMNFSEINSCMUNI PRIMARY KEY(NRPARAMNFSEINSCMUNI)
)
/
ALTER TABLE PARAMNFSEINSCMUNI ADD CONSTRAINT FKFIS00586PARAMNFSEINSMU FOREIGN KEY (CDEMPRESA, CDINSCMUNI) REFERENCES INSCRMUNICIP (CDEMPRESA, CDINSCMUNI)
/
ALTER TABLE PARAMNFSEINSCMUNI ADD CONSTRAINT CKC_IDAMBIENTE_PARAMNFSEINSMU CHECK ((IDAMBIENTE IN ('1', '2')))
/
ALTER TABLE PARAMNFSEINSCMUNI ADD CONSTRAINT CKC_IDLOCALSERV_PARAMNFSEINSMU CHECK ((IDLOCALSERVIDOR IN ('1', '2')))