Preparing Tables for Conflict Resolution
To use any conflict-resolution rule other than ignore or always-apply, you must define the shadow columns, cdrserver and cdrtime in the tables on both the source and target servers involved in replication.
To define the cdrserver and cdrtime shadow columns when you create a new table, use the WITH CRCOLS clause. For example, the following statement creates a new table named customer with a data column named id and the two shadow columns:
CREATE TABLE customer(id int) WITH CRCOLS;
To add the cdrserver and cdrtime shadow columns to an existing replicated table:
- Set alter mode on the table by running the cdr alter --on command.
- Alter the table using the ADD CRCOLS clause.
- Unset alter mode on the table by running the cdr alter --off command.
Adding CRCOLS columns to an existing table can result in a slow alter operation if any of the table columns have data types that require a slow alter. If a slow alter operation is necessary, make sure you have disk space at least twice the size of the original table, plus extra log space.
For example, the following statement adds the shadow columns to an existing table named customer:
ALTER TABLE customer ADD CRCOLS;
You cannot drop conflict resolution shadow columns while replication is active. To drop the cdrserver and cdrtime shadow columns, stop replication and then use the DROP CRCOLS clause with the ALTER TABLE statement. For example, the following statement drops the two shadow columns from a table named customer:
ALTER TABLE customer DROP CRCOLS;