Changing or re-creating primary key columns

You can change or re-create the primary key columns definition of a replicated table while replication is active.

About this task

You can change the primary key columns without restriction if either of the following conditions are true:

  • The table uses ERKEY shadow columns or another unique index or constraint as the replication key.
  • The primary key contains multiple columns. The column modification implicitly re-creates the primary key.

To change a primary key column if the primary key is a single column, enclose the primary key column modification and the primary key recreation operations in a single transaction. If you frequently update a primary key that is a single column, consider changing the replication key to another unique index or constraint.

Procedure

To drop and re-create a primary key:
  1. Set alter mode by running the cdr alter on command.
  2. Drop the primary key columns.
  3. Create the new primary key columns.
  4. Unset alter mode by running the cdr alter off command.