oracle-databaseoracle-golden-gate

Oracle GoldenGate When Table column is generate always identity type_IT does not let insert in target DB table


Trying to replicate the data into the replica DB (target) from source DB, using Oracle Golden Gate (OGG). Let's say I have TableA and B in source DB. A has identity column managed by a trigger which add unique number using sequence object (the old Oracle way, prior to 12C). The table B has identity column as "GENERATE ALWAYS AS IDENTITY ...", the way came newly in 12C. Now below is my observation, followed by question: (A) SourceDB TableA, insert 1 record, id=1. Then in TargetDB TableA, OGG replicates 1 insert, id=1. Good.

Source A------------------------------------Target A
id=1----------------------------------------id=1

(B) In TargetDB, manually insert 1 record, it gets done, id=3. Good. Here id should have been 2 but OGG skips 2 and set id of this newly added record in Target table as 3.

Source A------------------------------------Target A
id=1----------------------------------------id=1
.-------------------------------------------id=3

(C) SourceDB TableA, insert 1 record, id=2. Then in TargetDB TableA, OGG replicates 1 insert, id=2. Good.

Source A------------------------------------Target A
id=1----------------------------------------id=1
.-------------------------------------------id=3
id=2----------------------------------------id=2

So, apart from the nice behavior of the OGG it looks good! But when the same thing I try to do on the TableB, it gives me unique constraint error in Step B!! It looks like because the Table B the identity column is defined as Generate Always as Identity. So, it is really because of this? And this new way cause more problem then the old way of using sequence.nextValue object to generate new unique id column. Or there is any way in OGG to overcome this and make this table B behave same as Table A, for the step B?


Solution

  • Let's split your question in the two scenarios:

    SEQUENCES

    For a sequence, you can ONLY replicate in one-way replications. This means You can't replicate a sequence in an two-way or multi-way replication. You can ONLY replicate in an active-passive HA (high availability) not an active-active HA setup. You need to turn off the sequence replication by:

    During a replication, Oracle GoldenGate captures the sequence updates and makes sure the target sequence value is equal or higher than the source sequence number:

    IDENTITY COLUMNS

    Capture and replication of identity columns are supported by integrated processes from OGG v18 onwards.