Using the WITH ERKEY Keywords

Use the WITH ERKEY keywords to create the ERKEY shadow columns that Enterprise Replication uses for a replication key.

The ERKEY shadow columns (ifx_erkey_1, ifx_erkey_2, and ifx_erkey_3) are visible shadow columns because they are indexed and can be viewed in system catalog tables. After you create the ERKEY shadow columns, a new unique index and a unique constraint are created on the table using these columns. Enterprise Replication uses that index as the replication key.

For most database operations, the ERKEY columns are hidden. For example, if you include the WITH ERKEY keywords when you create a table, the ERKEY columns have the following behavior:
  • They are not returned by queries that specify an asterisk ( * ) as the projection list, as in the statement:
    SELECT * FROM tablename;
  • They do appear in DB-Access when you ask for information about the columns of the table.
  • They are included in the number of columns (ncols) in the systables system catalog table entry for tablename.
To view the contents of the ERKEY columns, you must explicitly specify the columns in the projection list of a SELECT statement, as the following example shows:
SELECT ifx_erkey_1, ifx_erkey_2, ifx_erkey_3 FROM customer;

Example

In the following example, the ERKEY shadow columns are added to the customer table:

CREATE TABLE customer (id INT) WITH ERKEY;