isql - - <<EOT

DATABASE gc;


create table  at_vfer 
  (
    code date,
    libel char(25)
  );
create unique index  ix_vfer01 on  at_vfer (code);


create table  at_atel 
  (
    code char(2),
    desig char(25)
  );
create unique index  ix_atel01 on  at_atel (code);

create table  at_vtech 
  (
    code char(2),
    nom char(25),
    prenom char(25),
    atel0 char(2),
    quot float,
    atel1 char(2),
    atel2 char(2),
    atel3 char(2),
    atel4 char(2),
    atel5 char(2),
    jrs1 smallint,
    jrs2 smallint,
    jrs3 smallint,
    jrs4 smallint,
    jrs5 smallint,
    jrs6 smallint,
    jrs7 smallint
  );
create unique index  ix_vtech01 on  at_vtech (code);


create table  at_vcateg 
  (
    code char(4),
    desig char(25),
    nbrh float,
    priorite smallint,
    tarif float,
    rev float
  );
create unique index  ix_vcateg01 on  at_vcateg (code);


create table  at_zon 
  (
    code char(4),
    desig char(25),
    tmps float,
    tarif float,
    rev float
  );


create table  at_quest 
  (
    code char(4),
    numlig smallint,
    texte char(30)
  );
create unique index  ix_quest01 on  at_quest (code,numlig);

create table  at_cntr 
  (
    code char(10),
    model char(12),
    serie char(20),
    rsoc char(25),
    ad1 char(25),
    ad2 char(25),
    cpv char(25),
    typgar smallint,
    ddeb date,
    dfin date
  );
create unique index  ix_atcntr01 on  at_cntr (code);
create index  ix_atcntr02 on  at_cntr (rsoc);
create index  ix_atcntr03 on  at_cntr (dfin,rsoc);
create index  ix_atcntr04 on  at_cntr (ddeb,rsoc);

create table at_cdp 
  (
    code char(5),
    nom char(25),
    sect char(4),
    zon char(2)
  );
create unique index ix_atcdp02 on at_cdp (nom);


create table at_vdos 
  (
    nodos char(6),
    stade smallint,
    dat date,
    hr integer,
    usercreat char(8),
    repar smallint,
    cli char(25),
    adcli_ad1 char(25),
    adcli_ad2 char(25),
    adcli_cpv char(25),
    telcli char(25),
    clifac char(25),
    adfac_ad1 char(25),
    adfac_ad2 char(25),
    adfac_cpv char(25),
    serie char(20),
    stock smallint,
    type char(4),
    model char(12),
    categ char(4),
    nofac char(10),
    dtach date,
    pan0 char(60),
    pan1 char(60),
    pan2 char(60),
    acc0 char(60),
    acc1 char(60),
    stk0 char(20),
    stk1 char(20),
    gar smallint,
    sec char(2),
    tech char(2),
    tmps float,
    dtrep date,
    reprise date,
    avecpret smallint,
    serpret char(20),
    interv0 char(60),
    interv1 char(60),
    interv2 char(60),
    interv3 char(60),
    nbhr float,
    marque char(6),
    codapp char(12),
    etatpret char(40),
    rev float,
    caht float,
    cattc float,
    livr smallint,
    hrrv integer,
    stadrel smallint,
    dtpret date,
    nbrepl smallint,
    repdom smallint,
    modif smallint,
    hrrep integer,
    acmpt float,
    dtcmpt date,
    mdreg smallint,
    hrfac float,
    revp float,
    nodep smallint,
    delaig smallint,
    tarif  float,
    achat  float,
    mtcaution float,
    nochqcaut char(20),
    mtdevis float,
    mtrepar float,
    newfac char(10),
    nochqac char(15)
  );

create unique index ix_vdos01 on at_vdos (nodos);
create index ix_vdos02 on at_vdos (cli);
create index ix_vdos03 on at_vdos (dat,stade);
create index ix_vdos04 on at_vdos (reprise,stade);
create index ix_vdos05 on at_vdos (tech,dat);
create index ix_vdos06 on at_vdos (tech,reprise);
create index ix_vdos07 on at_vdos (stade);

create table at_nodos 
  (
    num serial not null,
    ind smallint
  );

create unique index ix436_1 on at_nodos (num);

create table at_pars 
  (
    nbjcp smallint,
    priorite float,
    tvahr smallint,
    delai0 smallint,
    delai1 smallint,
    delai2 smallint,
    delai3 smallint,
    jour smallint,
    delcli0 smallint,
    delcli1 smallint,
    delcli2 smallint,
    delcli3 smallint,
    nbjrgard smallint,
    tarjrg float,
    dellivr float,
    depaspourc float,
    seuilprim float,
    valprim float,
    coutfix1 float,
    coutfix2 float,
    coutfix3 float,
    coutfix4 float,
    coutfix5 float,
    coutfix6 float,
    coutfix7 float,
    coutfix8 float,
    coutfix9 float,
    coutfix10 float,
    coutfix11 float,
    coutfix12 float,
    jour2 smallint,
    passcaut char(13),   
    codehr char(12),
    codedep char(12),
    codefg char(12) 
  );

create table at_plan 
  (
    tech char(2),
    coddos char(6),
    dtrep date,
    nbrh float,
    nsk serial not null,
    priorite smallint,
    typr smallint,
    sec char(2)
  );

create unique index ix_plan01 on at_plan (nsk);
create index ix_plan02 on at_plan (coddos);
create index ix_plan03 on at_plan (tech,dtrep);
create index ix_plan04 on at_plan (dtrep);

create table at_vld 
  (
    nodos char(6),
    numlig smallint,
    codart char(12),
    qtt float,
    px float,
    nocom char(7),
    qtcom float,
    desig char(40),
    hrst smallint,
    rev float
  );

create unique index ix_atvld01 on at_vld (nodos,numlig);
create index ix_atvld02 on at_vld (nocom,codart); 

create table at_ctec 
  (
    code char(2),
    mois smallint,
    annee smallint,
    cahg float,
    revhg float,
    sorrephg smallint,
    sorrepg smallint,
    revg float,
    sorret smallint,
    datcum date,
    nbhrhg float,
    revhrhg float,
    nbent float,
    nbces smallint,
    nbext smallint,
    nbhrgar float,
    nbcese smallint,
    entrep smallint,
    entces smallint,
    entmdf smallint,
    entext smallint,
    sorces smallint,
    sormdf smallint,
    sorext smallint,
    nbhrg float,
    revhrg float,
    cag float,
    hrfacg float,
    hrfachg float,
    nbhrm float,
    nbhrc float,
    revpg float
  );

create unique index ix_atctec01 on at_ctec (code,datcum);

create table at_cat 
  (
    code char(2),
    mois smallint,
    annee smallint,
    cahg float,
    revhg float,
    sorrephg smallint,
    sorrepg smallint,
    revg float,
    sorret smallint,
    datcum date,
    nbhrhg float,
    revhrhg float,
    nbent float,
    entrep smallint,
    entces smallint,
    entmdf smallint,
    entext smallint,
    sorces smallint,
    sormdf smallint,
    sorext smallint,
    nbhrg float,
    revhrg float,
    cag float,
    revpg float
  );

create unique index ix_atcat01 on at_cat (code,datcum);


create table at_cmdl 
  (
    code char(12),
    mois smallint,
    annee smallint,
    cahg float,
    revhg float,
    sorrephg smallint,
    sorrepg smallint,
    revg float,
    sorret smallint,
    datcum date,
    nbhrhg float,
    revhrhg float,
    nbent float,
    entrep smallint,
    entces smallint,
    entmdf smallint,
    entext smallint,
    sorces smallint,
    sormdf smallint,
    sorext smallint,
    nbhrg float,
    revhrg float,
    cag float,
    revpg float
  );

create unique index ix_atcmdl01 on at_cmdl (code,datcum);

create table at_cmarq 
  (
    code char(6),
    mois smallint,
    annee smallint,
    cahg float,
    revhg float,
    sorrephg smallint,
    sorrepg smallint,
    revg float,
    sorret smallint,
    datcum date,
    nbhrhg float,
    revhrhg float,
    nbent float,
    entrep smallint,
    entces smallint,
    entmdf smallint,
    entext smallint,
    sorces smallint,
    sormdf smallint,
    sorext smallint,
    nbhrg float,
    revhrg float,
    cag float,
    revpg float
  );

create unique index ix_atcmarq01 on at_cmarq (code,datcum);

create table  at_marq
  (
    code char(6),
    desig char(25)
  );
create unique index  ix_marq01 on  at_marq (code);

CLOSE DATABASE;

EOT

chmod 666 $DBPATH/gc.dbs/*.idx
chmod 666 $DBPATH/gc.dbs/*.dat
 
 
