1 Table

It allows defining the structure of a table to be created in the database. The root element is table which, in turn, can contain the following elements:

  • column: allows defining the columns that make up the table.
  • primary: allows defining the primary key of the table.
  • unique: allows defining uniqueness restrictions of the table.
  • index: allows defining indexes on the table.
  • foreign: allows defining the foreign keys of the table.
  • check: allows defining control restrictions on the table columns.

Information

It is important to respect the order of the elements specified above, otherwise the XML to SQL code transformer returns an error message or produces unwanted statements.

It allows generating a table on database.

<table
    name='name'
    temp='y|yes|n|no'
    log='y|yes|n|no'
    type='type'
    under='under'
    onexception='ignore'
>
    <column /> *
    <primary /> ?
    <unique /> *
    <index /> *
    <foreign /> *
    <check /> *
</table>
Example

Taking into account the attributes of the table, there are two ways to create a table.
Without the attribute type: to create the structure of this table the tag column will be used indicating the column name and type.

Copy
<table name='gcliente'>
    <column name='codigo' type='integer' />
    <column name='varlog' type='char' size='4' />
</table>
Example

With the type attribute: the temporary table will be created without the need to define the columns that will build up it. To do this, a structure already created on a type object will be used.

Copy
<table name='t_extend' type='r_main'>
   <primary name='pk_t_main' columns='codigo' />
</table>
Example

If you want to create a table with the structure of a type element and some other column, you simply have to add the tag 'column'.

Copy
<table name='t_extend' type='r_main'>
    <column name='desc' type='char' size='40' />
    <primary name='pk_t_main' columns='codigo' />
</table>
 

1.1 Column

It allows defining the columns that make up a table.

<column
    name='name'
    type='type'
    size='size'
    type_like='type_like'
    default='default'
    required='required'
/>
Example

Taking into account the attributes of the table, there are two ways to create a table.
Without the attribute type: to create the structure of this table the tag column will be used indicating column name and type.

Copy
<column name='gid' type='serial' required='yes' />
<column name='cat' type='integer' />
<column name='asother' type_like='table.column' required='yes' />
<column name='fips_cntry' type='varchar'  size='80' />
<column name='cntry_name' type='varchar'  size='80' />
<column name='area' type='decimal'  size='14,2' />
<column name='pop_cntry' type='decimal'  size='14,2' />
 

1.2 Primary

This element must be defined within the table element, and allows indicating the primary key of table.

<primary
    name='name'
    columns='columns'
    table='table'
/>
Example
Copy
<primary name='p_cbancpro' columns='empcode,ctafin' />
 

1.3 Unique

This element is defined within the table element, and is used to create a restriction of type unique constraint.

<unique
    name='name'
    columns='columns'
    oracle='oracle'
/>
Example
Copy
<unique name='u_cbancpro2' columns='ctafin,empcode' />
 

1.4 Anchor

This element must be defined within the 'table' element, and allows you to specify the table indexes.

<index
    name='name'
    columns='columns'
    oracle='oracle'
/>
Example
Copy
<index name='i_wic_jrep_box_celldata1'
    columns='rep_code, box_row, box_col, box_when'
    unique='y'
    oracle='no'
/>
 

1.5 Foreign

This element must be defined within the 'table' element, and allows indicating the foreign keys of table.

<foreign
    name='name'
    columns='columns'
    references='references'
    refcols='refcols'
    table='table'
    unique='y|yes'
    ondeletecascade='y|yes'
    conditional='y|yes'
/>
Example
Copy
<foreign
    name='f_wic_change_logrcs1'
    columns='chg_seqno'
    references='wic_change_log'
    refcols='chg_seqno'
    conditional='y'
/>
 

1.6 Check

This tag must be inside a 'table' tag, and it is used to specify the validation checks that the table will use.

<check
    name='name'
    engine='engine'
>
    <constraint /> *
</check>
Example
Copy
<check name='c_gartdele1'>
    <constraint>
        codpot IN ('P', 'C', '0')
    </constraint>
</check>
Example
Copy
<check name='c_gartdele2'>
    <constraint>
        fecini <= fecfin
    </constraint>
</check>