Tables with a Primary Key Derived from a Unique Index

In the absence of a primary key on a table, MySQL will promote a unique index to primary key if the indexed column is NOT NULL. If there are more than one of these not-null indexes, the first one that was created becomes the primary key. To avoid Replicat errors, create these indexes in the same order on the source and target tables.

For example, assume that source and target tables named ggvam.emp each have columns named first, middle, and last, and all are defined as NOT NULL. If you create unique indexes in the following order, Oracle GoldenGate will abend on the target because the table definitions do not match.

Source:

mysql> create unique index uq1 on ggvam.emp(first); 
mysql> create unique index uq2 on ggvam.emp(middle); 
mysql> create unique index uq3 on ggvam.emp(last); 

Target:

mysql> create unique index uq1 on ggvam.emp(last); 
mysql> create unique index uq2 on ggvam.emp(first); 
mysql> create unique index uq3 on ggvam.emp(middle); 

The result of this sequence is that MySQL promotes the index on the source "first" column to primary key, and it promotes the index on the target "last" column to primary key. Oracle GoldenGate will select the primary keys as identifiers when it builds its metadata record, and the metadata will not match. To avoid this error, decide which column you want to promote to primary key, and create that index first on the source and target.