Creating replicated tables through a grid

You can automatically create a replicate and start replication when you create a table through the grid.

Before you begin

If the table you are creating is a typed table, you must define a primary key.

If you plan to create a table with a TimeSeries column, all grid servers must be running HCL OneDB™ version 12.10 or later.

About this task

When you enable replication while creating a table through a grid, replication is set up in the following way:
  • A replicate is created for the table. The replicate name is based on the name of the source server. Use the cdr list replicate command to see the name.
  • All servers that are members of the grid are included as participants in the replicate.
  • The replicate is included in a replicate set that has the same name as the grid.
  • The conflict resolution rule for the replicate is time stamp if you include the WITH CRCOLS clause. Otherwise, the conflict resolution rule is always apply.
  • The ERKEY shadow columns are automatically added to the table.
  • All other replicate properties are the same as the default properties of a replicate created through a template.

Procedure

To set up replication:
  1. Connect to the grid by running the ifx_grid_connect() procedure with the ER_enable argument set to 1.
  2. Run a CREATE TABLE statement. Include the WITH CRCOLS clause if you want time stamp conflict resolution.
  3. Disconnect from the grid by running the ifx_grid_disconnect() procedure.

Example

The following example creates a table with replication enabled that uses the time stamp conflict resolution rule:

EXECUTE PROCEDURE ifx_grid_connect('grid1', 1);

CREATE TABLE special_offers(
    offer_description varchar(255),
    offer_startdate   date,
    offer_enddate     date,
    offer_rules       lvarchar)
    WITH CRCOLS;

EXECUTE PROCEDURE ifx_grid_disconnect();

What to do next

If you need to alter or delete a database object that you created through a grid, perform those operation from within a grid context. For example, do not create a table from within a grid and then delete the table on one of the replication servers outside of a grid context. Instead, delete the table through the grid.