@PHOLHAD

CREATE TABLE PHTMUN (
    CODIGO  VARCHAR(8) NOT NULL,
    CIDADE  VARCHAR(80),
    ESTADO  VARCHAR(2),
    NUMDDD  VARCHAR(4),
    NUMCEP  VARCHAR(5),
PRIMARY KEY (CODIGO)
);
@EXECSQL



CREATE TABLE PHTTRC 
(
    CODTRC  VARCHAR(8) NOT NULL,
    NOMINT  VARCHAR(30),
    RAZSOC  VARCHAR(80),
    TIPLOG  VARCHAR(4),
    DESLOG  VARCHAR(10),
    ENDERE  VARCHAR(80),
    NUMERO  VARCHAR(10),
    COMPLE  VARCHAR(30),
    BAIRRO  VARCHAR(30),
    CODMUN  VARCHAR(8),
    CIDADE  VARCHAR(40),
    ESTADO  VARCHAR(2),
    NUMCEP  VARCHAR(6),
    CMPCEP  VARCHAR(4),
    NUMDDD  VARCHAR(4),
    TELEF1  VARCHAR(15),
    TELEF2  VARCHAR(15),
    CONTA1  VARCHAR(40),
    CONTA2  VARCHAR(40),
    ENDNET  VARCHAR(80),
    TIPINS  VARCHAR(2),
    NUMINS  VARCHAR(20),
    NUMCEI  VARCHAR(20),
    INSEST  VARCHAR(20),
    OUTINS  VARCHAR(20),
    NUMCAE  VARCHAR(20),
    NUMCNO  VARCHAR(20),
    NUMPRC  VARCHAR(30),
 PRIMARY KEY (CODTRC)
);
@EXECSQL

CREATE TABLE PHTEMP7
(
    CODEMP  VARCHAR(4) NOT NULL,
    SEQUEN  VARCHAR(4) NOT NULL,
    CERNUM  VARCHAR(40),
    CERORG  VARCHAR(10),
    CEREMI  VARCHAR(10),
    CERVCT  VARCHAR(10),
    CERNPR  VARCHAR(40),
    CERDPR  VARCHAR(10),
    CERPUB  VARCHAR(10),
    CERPAG  VARCHAR(6),

 PRIMARY KEY (CODEMP, SEQUEN)
);
@EXECSQL

CREATE TABLE PHTEMP8
(
    CODEMP  VARCHAR(4) NOT NULL,
    SEQUEN  VARCHAR(4) NOT NULL,
    PRCNUM  VARCHAR(30),
    PRCTIP  VARCHAR(2),
    PRCREF  VARCHAR(2),
    PRCTPD  VARCHAR(2),
    PRCDTD  VARCHAR(10),
    PRCIDP  VARCHAR(2),
    PRCVAR  VARCHAR(4),
    PRCMUN  VARCHAR(8),
    PRCCID  VARCHAR(40),
    PRCEST  VARCHAR(2),
    PRCAUT  VARCHAR(2),
    PRCEXT  VARCHAR(2),
    PRCRUB  VARCHAR(150),

 PRIMARY KEY (CODEMP, SEQUEN)
);
@EXECSQL


CREATE TABLE PHTJOR (
    TABJOR  VARCHAR(4) NOT NULL,
    CODJOR  VARCHAR(4) NOT NULL,
    DESCRI  VARCHAR(80),
    HORENT  VARCHAR(5),
    HORSAI  VARCHAR(5),
    HORFLX  VARCHAR(2),  
    TIPINT  VARCHAR(2),
    TOTHRS  VARCHAR(5),
    TIPJOR  VARCHAR(2),  
    TIPIN1  VARCHAR(2),
    INIIN1  VARCHAR(5),
    FININ1  VARCHAR(5),
    TIPIN2  VARCHAR(2),
    INIIN2  VARCHAR(5),
    FININ2  VARCHAR(5),
    TIPIN3  VARCHAR(2),
    INIIN3  VARCHAR(5),
    FININ3  VARCHAR(5),
    TIPIN4  VARCHAR(2),
    INIIN4  VARCHAR(5),
    FININ4  VARCHAR(5),
    TIPIN5  VARCHAR(2),
    INIIN5  VARCHAR(5),
    FININ5  VARCHAR(5),  
PRIMARY KEY (TABJOR, CODJOR)
);
@EXECSQL


CREATE TABLE PHTFRE (
    TABJOR  VARCHAR(4) NOT NULL,
    CODFRE  VARCHAR(4) NOT NULL,
    DESCRI  VARCHAR(80),
    TIPFRE  VARCHAR(2),
    CDJOR1  VARCHAR(4),
    CDJOR2  VARCHAR(4),
    CDJOR3  VARCHAR(4),
    CDJOR4  VARCHAR(4),
    CDJOR5  VARCHAR(4),
    CDJOR6  VARCHAR(4),
    CDJOR7  VARCHAR(4),
    TOTSEM  VARCHAR(6),
    TOTMES  VARCHAR(6),
    INDDES  VARCHAR(2),
    DESHR1  VARCHAR(150),
    DESHR2  VARCHAR(150),
PRIMARY KEY (TABJOR, CODFRE)
);
@EXECSQL


CREATE TABLE PHTCRG
(
  TABCRG  VARCHAR(4) NOT NULL,
  CODCRG  VARCHAR(8) NOT NULL,
  DESCRI  VARCHAR(100),
  ABREVI  VARCHAR(50),
  NUMCBO  VARCHAR(10),
  DESCRG  VARCHAR(256),
  INDBLQ  VARCHAR(2),
 PRIMARY KEY (TABCRG, CODCRG)
);
@EXECSQL

CREATE TABLE PHTFNC
(
  TABFNC  VARCHAR(4) NOT NULL,
  CODFNC  VARCHAR(8) NOT NULL,
  DESCRI  VARCHAR(100),
  ABREVI  VARCHAR(50),
  NUMCBO  VARCHAR(10),
  DESFNC  VARCHAR(256),
  INDBLQ  VARCHAR(2),
 PRIMARY KEY (TABFNC, CODFNC)
);
@EXECSQL

CREATE TABLE PHTAMB
(
  TABAMB  VARCHAR(4) NOT NULL,
  CODAMB  VARCHAR(8) NOT NULL,
  DESCRI  VARCHAR(100),
  DESAMB  VARCHAR(200), 
  LOCAMB  VARCHAR(2),
  TIPINS  VARCHAR(2),
  NUMINS  VARCHAR(20),
  INDBLQ  VARCHAR(2),
 PRIMARY KEY (TABAMB, CODAMB)
);
@EXECSQL

CREATE TABLE PHTAMB2
(
  TABAMB  VARCHAR(4) NOT NULL,
  CODAMB  VARCHAR(8) NOT NULL,
  SEQUEN  VARCHAR(4) NOT NULL, 
  DESCRI  VARCHAR(50),
  FRISC1  VARCHAR(2),
  FRISC2  VARCHAR(4),
  FRISC3  VARCHAR(6),
  FRISC4  VARCHAR(8),
  FRISC5  VARCHAR(10),
  USOEPC  VARCHAR(2),
 PRIMARY KEY (TABAMB, CODAMB, SEQUEN)
);
@EXECSQL


CREATE TABLE PHCCJG 
(
  CODEMP VARCHAR(4) NOT NULL,
  CODCAD VARCHAR(10) NOT NULL,
  SEQUEN VARCHAR(4) NOT NULL,
  NOMCON VARCHAR(40),
  DATNAS VARCHAR(10),
  CODSEX VARCHAR(2),
  CODNAC VARCHAR(2),
  NUMCPF VARCHAR(15),
  DATCAS VARCHAR(10),
  REGIME VARCHAR(2),
  DATBXA VARCHAR(10),
  MOTBXA VARCHAR(10),
  DESMOT VARCHAR(80),
  DEPIRF VARCHAR(2),
  BNFCPA VARCHAR(2),
  PSAUDE VARCHAR(2),
PRIMARY KEY (CODEMP, CODCAD, SEQUEN)
);
@EXECSQL

CREATE TABLE PHCASO (
    CODEMP  VARCHAR(4) NOT NULL,
    CODCAD  VARCHAR(10) NOT NULL,
    SEQUEN  VARCHAR(4) NOT NULL,
    DATASO  VARCHAR(10),
    IDENTI  VARCHAR(40),
    IDEASO  VARCHAR(2),
    TIPASO  VARCHAR(2),
    RESASO  VARCHAR(2),
    CODMED  VARCHAR(4),
    NOMMED  VARCHAR(50),
    NUMREG  VARCHAR(20),
    UFNREG  VARCHAR(2),
    OBSERV  VARCHAR(80),
    RSPNIS  VARCHAR(20),
    RSPNOM  VARCHAR(50),
    RSPCLS  VARCHAR(10),
    RSPUFC  VARCHAR(2),
    CNESCD  VARCHAR(10),
    CNESCT  VARCHAR(50),
    CNESEM  VARCHAR(50),
    MBICMD  VARCHAR(4),
    MBINMD  VARCHAR(50),
    MBINRG  VARCHAR(20),
    MBIUFR  VARCHAR(2),
PRIMARY KEY (CODEMP, CODCAD, SEQUEN)
);
@EXECSQL

CREATE TABLE PHCMBI (
    CODEMP  VARCHAR(4) NOT NULL,
    CODCAD  VARCHAR(10) NOT NULL,
    SEQUEN  VARCHAR(4) NOT NULL,
    SEQASO  VARCHAR(4), 
    IDENTI  VARCHAR(40),
    AGEQUI  VARCHAR(4), 
    MATBIO  VARCHAR(2),
    CODANA  VARCHAR(6),
    INTEXA  VARCHAR(2), 
    ORDEXA  VARCHAR(2),
    INDRSL  VARCHAR(2), 
    INIMBI  VARCHAR(10),
    FINMBI  VARCHAR(10), 
    OBSERV  VARCHAR(80),

PRIMARY KEY (CODEMP, CODCAD, SEQUEN)
);
@EXECSQL


CREATE TABLE PHCCDT (
    CODEMP  VARCHAR(4) NOT NULL,
    CODCAD  VARCHAR(10) NOT NULL,
    SEQCDT  VARCHAR(4) NOT NULL,
    TIPCDT  VARCHAR(2),
    IDENTI  VARCHAR(40),
    CODAMB  VARCHAR(4),
    DATINI  VARCHAR(10),
    DATFIN  VARCHAR(10),
    DESATI  VARCHAR(100),
    FRISC1  VARCHAR(2),
    FRISC2  VARCHAR(4),
    FRISC3  VARCHAR(6),
    FRISC4  VARCHAR(8),
    FRISC5  VARCHAR(10),
    INTCON  VARCHAR(20),
    TECMED  VARCHAR(40),
    USOEPI  VARCHAR(2),
    OBSERV  VARCHAR(80),
PRIMARY KEY (CODEMP, CODCAD, SEQCDT)
);
@EXECSQL

CREATE TABLE PHCCDT2 (
    CODEMP  VARCHAR(4) NOT NULL,
    CODCAD  VARCHAR(10) NOT NULL,
    SEQCDT  VARCHAR(4) NOT NULL,  
    SEQEPI  VARCHAR(4) NOT NULL,
    CODEPI  VARCHAR(20),
    DESCRI  VARCHAR(60),
    INDPRO  VARCHAR(2), 
    INDFUN  VARCHAR(2),
    INDVAL  VARCHAR(2),
    INDPER  VARCHAR(2),
    INDHIG  VARCHAR(2),
PRIMARY KEY (CODEMP, CODCAD, SEQCDT, SEQEPI)
);
@EXECSQL





CREATE TABLE PHCEMPA 
(
    CODEMP  VARCHAR(4) NOT NULL,
    CODCAD  VARCHAR(10) NOT NULL,
    SEQUEN  VARCHAR(4) NOT NULL,
    NOMINT  VARCHAR(30),
    RAZSOC  VARCHAR(80),
    TIPLOG  VARCHAR(4),
    DESLOG  VARCHAR(10),
    ENDERE  VARCHAR(80),
    NUMERO  VARCHAR(10),
    COMPLE  VARCHAR(30),
    BAIRRO  VARCHAR(30),
    CODMUN  VARCHAR(8),
    CIDADE  VARCHAR(40),
    ESTADO  VARCHAR(2),
    NUMCEP  VARCHAR(6),
    CMPCEP  VARCHAR(4),
    NUMDDD  VARCHAR(4),
    TELEF1  VARCHAR(15),
    TELEF2  VARCHAR(15),
    CONTA1  VARCHAR(40),
    CONTA2  VARCHAR(40),
    ENDNET  VARCHAR(80),
    TIPINS  VARCHAR(2),
    NUMINS  VARCHAR(20),
    MATRIC  VARCHAR(20), 
    DATADM  VARCHAR(10), 
    DATDEM  VARCHAR(10), 
    FUNCAO  VARCHAR(50), 
    OBSERV  VARCHAR(80), 
 PRIMARY KEY (CODEMP, CODCAD, SEQUEN)
);
@EXECSQL

CREATE TABLE PHCEMPC 
(
    CODEMP  VARCHAR(4) NOT NULL,
    CODCAD  VARCHAR(10) NOT NULL,
    SEQUEN  VARCHAR(4) NOT NULL,
    NOMINT  VARCHAR(30),
    RAZSOC  VARCHAR(80),
    TIPLOG  VARCHAR(4),
    DESLOG  VARCHAR(10),
    ENDERE  VARCHAR(80),
    NUMERO  VARCHAR(10),
    COMPLE  VARCHAR(30),
    BAIRRO  VARCHAR(30),
    CODMUN  VARCHAR(8),
    CIDADE  VARCHAR(40),
    ESTADO  VARCHAR(2),
    NUMCEP  VARCHAR(6),
    CMPCEP  VARCHAR(4),
    NUMDDD  VARCHAR(4),
    TELEF1  VARCHAR(15),
    TELEF2  VARCHAR(15),
    CONTA1  VARCHAR(40),
    CONTA2  VARCHAR(40),
    ENDNET  VARCHAR(80),
    TIPINS  VARCHAR(2),
    NUMINS  VARCHAR(20),
    MATRIC  VARCHAR(20), 
    DATADM  VARCHAR(10), 
    DATDEM  VARCHAR(10), 
    FUNCAO  VARCHAR(50), 
    OBSERV  VARCHAR(80), 
    IDONUS  VARCHAR(2),
 PRIMARY KEY (CODEMP, CODCAD, SEQUEN)
);
@EXECSQL


CREATE TABLE PHCEXT 
(
    CODEMP  VARCHAR(4) NOT NULL,
    CODCAD  VARCHAR(10) NOT NULL,
    LOGRAD  VARCHAR(80),
    NUMERO  VARCHAR(10),
    COMPLE  VARCHAR(40),
    BAIRRO  VARCHAR(40),
    CIDADE  VARCHAR(80),
    POSTAL  VARCHAR(20),
    CDPAIS  VARCHAR(6),
    TELEFO  VARCHAR(30),
    CELULA  VARCHAR(30),
    E_MAIL  VARCHAR(50),
    OBSERV  VARCHAR(50),
PRIMARY KEY (CODEMP, CODCAD)
);
@EXECSQL


CREATE TABLE PHCSTB (
    CODEMP  VARCHAR(4) NOT NULL,
    CODCAD  VARCHAR(10) NOT NULL,
    SEQUEN  VARCHAR(4) NOT NULL,
    IDENTI  VARCHAR(40),
    TIPSTB  VARCHAR(2),
    DATINI  VARCHAR(10),
    OBSINI  VARCHAR(80),
    QTDDIA  VARCHAR(4),
    DATFIN  VARCHAR(10),
    OBSFIN  VARCHAR(80),
    CODORI  VARCHAR(4), 
    SEQORI  VARCHAR(10),
PRIMARY KEY (CODEMP, CODCAD, SEQUEN)
);
@EXECSQL

CREATE TABLE PHCATD (
    CODEMP  VARCHAR(4) NOT NULL,
    CODCAD  VARCHAR(10) NOT NULL,
    SEQUEN  VARCHAR(4) NOT NULL,  
    IDENTI  VARCHAR(40),
    DATINI  VARCHAR(10),
    DATFIN  VARCHAR(10),
    DESCR1  VARCHAR(80),
    DESCR2  VARCHAR(80),
    DESCR3  VARCHAR(80),
    DESCR4  VARCHAR(80),
    OBSERV  VARCHAR(80), 
PRIMARY KEY (CODEMP, CODCAD, SEQUEN)
);
@EXECSQL

CREATE TABLE PHCDSI (
    CODEMP  VARCHAR(4) NOT NULL,
    CODCAD  VARCHAR(10) NOT NULL,
    CODTRC  VARCHAR(8),
    DATADM  VARCHAR(10),
    CATEGO  VARCHAR(4),
    MATRIC  VARCHAR(20),
    OBSERV  VARCHAR(80), 
PRIMARY KEY (CODEMP, CODCAD)
);
@EXECSQL

CREATE TABLE PHCSTG (
    CODEMP  VARCHAR(4) NOT NULL,
    CODCAD  VARCHAR(10) NOT NULL,
    NATEST  VARCHAR(2),
    NIVEST  VARCHAR(2),
    AREATU  VARCHAR(50),
    APOLIC  VARCHAR(30),
    DATTER  VARCHAR(10),
    INSTIT  VARCHAR(8),
    AGENTE  VARCHAR(8),
    NOMCOO  VARCHAR(50),
    CPFCOO  VARCHAR(15),
    OBSERV  VARCHAR(80), 
PRIMARY KEY (CODEMP, CODCAD)
);
@EXECSQL





CREATE TABLE PHMPRD (
    CODEMP  VARCHAR(4) NOT NULL,
    CODNIV  VARCHAR(2) NOT NULL, 
    TIPSRV  VARCHAR(2) NOT NULL, 
    ANOMES  VARCHAR(8) NOT NULL, 
    CODFOL  VARCHAR(2) NOT NULL,
    CODTOM  VARCHAR(4) NOT NULL,  
    SEQUEN  VARCHAR(4) NOT NULL, 
    NUMDOC  VARCHAR(10),
    SERDOC  VARCHAR(6), 
    CODTRC  VARCHAR(8), 
    NOMTRC  VARCHAR(80), 
    DATEMI  VARCHAR(10), 
    DATPAG  VARCHAR(10), 
    INDCOM  VARCHAR(2), 
    VALBRU  VARCHAR(14),
    VALRET  VARCHAR(14),
    GILRAT  VARCHAR(14),
    VSENAR  VARCHAR(14),
    PRCNUM  VARCHAR(30), 

PRIMARY KEY (CODEMP, CODNIV, TIPSRV, ANOMES, CODFOL, CODTOM, SEQUEN)
);
@EXECSQL

CREATE TABLE PHMPNI (
    CODEMP  VARCHAR(4) NOT NULL,
    CODNIV  VARCHAR(2) NOT NULL, 
    ANOMES  VARCHAR(8) NOT NULL, 
    CODFOL  VARCHAR(2) NOT NULL,
    CODTOM  VARCHAR(4) NOT NULL, 
    SEQUEN  VARCHAR(4) NOT NULL, 
    CODTRC  VARCHAR(8), 
    NOMTRC  VARCHAR(80), 
    DESCRI  VARCHAR(80), 
    DATPAG  VARCHAR(10), 
    VALLIQ  VARCHAR(14),
    BASIRF  VARCHAR(14), 
    VALIRF  VARCHAR(14),

PRIMARY KEY (CODEMP, CODNIV, ANOMES, CODFOL, CODTOM, SEQUEN)
);
@EXECSQL


CREATE TABLE PHMAVF (
    AVIDAT  VARCHAR(10) NOT NULL, 
    EMPCOD  VARCHAR(4)  NOT NULL,
    CADCOD  VARCHAR(10) NOT NULL, 
    FERANO  VARCHAR(4)  NOT NULL, 
    FERSEQ  VARCHAR(2)  NOT NULL,   
    DATAVI  VARCHAR(10),
    CODEMP  VARCHAR(4),
    CODCAD  VARCHAR(10),
    NOMFUN  VARCHAR(40),
    ANOFER  VARCHAR(4), 
    SEQFER  VARCHAR(2),
    DIAGOZ  VARCHAR(5), 
    INIGOZ  VARCHAR(10), 
    FINGOZ  VARCHAR(10), 
    DIAABO  VARCHAR(5),
    INIABO  VARCHAR(10), 
    FINABO  VARCHAR(10), 
    DATPAG  VARCHAR(10), 
    TIPFER  VARCHAR(2), 
    OBSER1  VARCHAR(80), 
    OBSER2  VARCHAR(80),
    INDCAL  VARCHAR(2), 
    PERCAL  VARCHAR(8),   
PRIMARY KEY (AVIDAT, EMPCOD, CADCOD, FERANO, FERSEQ)
);
@EXECSQL

CREATE TABLE PHMAVR (
    AVIDAT  VARCHAR(10) NOT NULL, 
    EMPCOD  VARCHAR(4)  NOT NULL,
    CADCOD  VARCHAR(10) NOT NULL, 
    DATAVI  VARCHAR(10),
    CODEMP  VARCHAR(4),
    CODCAD  VARCHAR(10),
    NOMFUN  VARCHAR(40),
    TIPAVI  VARCHAR(2), 
    TEMAVI  VARCHAR(2), 
    DIAAVI  VARCHAR(4), 
    AVIDEM  VARCHAR(2), 
    DATDEM  VARCHAR(10),
    CAUDEM  VARCHAR(4),
    DATPAG  VARCHAR(10), 
    LOCPAG  VARCHAR(80), 
    OBSER1  VARCHAR(80), 
    OBSER2  VARCHAR(80),   
    INDCAL  VARCHAR(2), 
    PERCAL  VARCHAR(8),  
    DATCNC  VARCHAR(10), 
    MOTCNC  VARCHAR(2), 
    OBSCN1  VARCHAR(80), 
    OBSCN2  VARCHAR(80),  
PRIMARY KEY (AVIDAT, EMPCOD, CADCOD)
);
@EXECSQL


CREATE TABLE PHWEFD (
    IDEARQ VARCHAR(10),
    CODIG1 VARCHAR(10),
    CODIG2 VARCHAR(10),
    CODIG3 VARCHAR(10),
    INSCRI VARCHAR(20),
    OPEDAT VARCHAR(10),
    DATOPE VARCHAR(10),
    HOROPE VARCHAR(8),
    SEQUEN VARCHAR(4),
    CODOPE VARCHAR(4),
    VALINI VARCHAR(8),
    VALFIN VARCHAR(8),
    OBSERV VARCHAR(40),
    IDEVEN VARCHAR(40),
    RECEFD VARCHAR(30)
);
@EXECSQL

CREATE TABLE PHWENV (
  CODGRU  VARCHAR(2), 
  SUBGRU  VARCHAR(8), 
  CODIG1  VARCHAR(18), 
  CODIG2  VARCHAR(18), 
  CODIG3  VARCHAR(18), 
  CODIG4  VARCHAR(18), 
  CODIG5  VARCHAR(18), 
  PHXUSU  VARCHAR(8),
  PHXDAT  VARCHAR(10),
  PHXHOR  VARCHAR(8),
  PHXOPE  VARCHAR(2),
  PHXEFD  VARCHAR(2),
  EFDUSU  VARCHAR(8),
  EFDDAT  VARCHAR(10),
  EFDHOR  VARCHAR(8)
);
@EXECSQL

