Preparing tables without primary keys
The data columns in your table might not need a primary key. To replicate tables that do not have primary keys, you can specify a unique index or add the ERKEY shadow columns.
About this task
You can specify an existing unique index or unique constraint as the replication key when you define the replicate. Use the --key or --anyUniqueKey option with the cdr define replicate or cdr define template commands.
If you create a replicated table through a grid, the ERKEY shadow columns are automatically created and included in the replicate definition.
Procedure
What to do next
- Run the ALTER TABLE statement with the ADD ERKEY clause. For example, the following statement adds the ERKEY shadow columns to an existing table named customer:
ALTER TABLE customer ADD ERKEY;
Occasionally, you might need to drop the ERKEY shadow columns; for example, if you are reverting to an earlier version of the database server.
To drop the ERKEY shadow columns from a replicated table:
- Run the cdr remaster command without the --erkey option.
- Run the DROP ERKEY clause with the ALTER TABLE statement.
For example, the following statement drops the ERKEY shadow columns from a table named customer:
ALTER TABLE customer DROP ERKEY;