To resync one or more tables/schemas on different SCN‘s using a single or minimum number of replicats without using handlecollisions.
For example, when doing migrations and parallel exports are run.
This can be done with Oracle goldenGate (OGG) 11.1.1.0.x or higher.
Consider the following example with the schema HR and two tables TCUSTORD,
TCUSTMER
The syntax given below is for OGG v11.x.
Please see the NOTE at the end for OGG v12 and higher
1. Capture the SCN information in the extract trails using tokens
table hr.*, Tokens (tk-csn = @GETENV
("TRANSACTION", "CSN")) ;
Step 1 can be skipped if using OGG v11.1.1.1.x and it is needed if using OGG
v11.1.1.0.x
On OGG v11.1.1.1.x and higher the TOKEN is
not needed in the extract as the CSN/SCN is written
by default to the OGG trails
2. Do an SCN based export on source for the interested tables (first TCUSTMER,
then TCUSTORD in
our example)
exp hr/hr tables=hr.tcustmer grants=n statistics=none
triggers=n compress=n FLASHBACK_SCN=4746443
Then run another export on source for TCUSTORD at a different scn
exp hr/hr tables=hr.tcustord grants=n statistics=none
triggers=n compress=n FLASHBACK_SCN=4747033
3. Run the imports on target
4. Add the replicat on target to the beginning of the extract trail
Example parameter file:
replicat r1
userid myogguser password xyz
assumetargetdefs
discardfile dirrpt\r1.dsc, purge
map hr.tcustmer, target myogguser.* , Filter ( @NUMSTR (@TOKEN
("TK-CSN")) > 4746443);
map hr.tcustord, target myogguser.* , Filter ( @NUMSTR (@TOKEN
("TK-CSN")) > 4747033);
This is used to resync one or more tables/ schemas of different SCN‘s in the
same replicat.
If not using tokens
in the extract on step 1 (OGG versions 11.1 and higher) then the equivalent
mapping to use the
default SCN token from the trail would be
map hr.tcustmer,
target myogguser.* , FILTER ( @GETENV ("TRANSACTION",
"CSN") > 4746443);
map hr.tcustord, target myogguser.* , FILTER ( @GETENV
("TRANSACTION", "CSN") > 4747033);
This example is for a DML only replication setup using OGG version
11.1.1.0.x or higher
NOTE: For OGGv12 the double quotes needs to be replaced
with single quotes since OGG v12 uses ANSI SQL parameter by default