Professional Documents
Culture Documents
Table created.
2) SQL> alter table mytab add constraint pk_mytab primary key (id);
Table altered.
3) We then create the extract process Testext on source and replicat process Testrep on
target.
extract testext
userid ggs_owner, password ggs_owner
rmthost 10.32.20.62, mgrport 7809
rmttrail /u01/app/goldengate/dirdat/gg
table sh.mytab;
REPLICAT testrep
ASSUMETARGETDEFS
USERID ggs_owner,PASSWORD ggs_owner
IGNOREDELETES
IGNOREUPDATES
MAP SH.MYTAB, TARGET SH.MYTAB;
4) Let us now test the same by inserting a row into the source table
1 row created.
SQL> commit;
ID COMMENTS
———- ——————–
1 INSERTED row
1 row updated.
SQL> commit;
ID COMMENTS
———- ——————–
1 UPDATED row
On the target, we see that the update to the row has not happened on the target database.
ID COMMENTS
———- ——————–
1 INSERTED row
1 row deleted.
SQL> commit;
Commit complete.
Check the target. We see that the row has not been deleted from the target database.
ID COMMENTS
———- ——————–
1 INSERTED row
7) On the source GoldenGate environment let us examine the statistics for the Extract
process. We see that 3 operations have happened. This is made up of one insert, update
and delete operation.
Output to /u01/app/goldengate/dirdat/gg:
8) On the target however we see that only one single Insert operation has taken place.
Ok. Now the source table has no rows while the target table has one row.
What happens when we insert two rows into the source table?
1 row created.
1 row created.
SQL> commit;
Commit complete.
Since the row with ID=1 already existed in the target database (because it was not deleted when
the delete happened on the source), the subsequent insert fails and we see this error in the replicat
log file.
We need to tell the Replicat process that it needs to ignore the insert for the row which
already exists and for this purpose we use the GoldenGate utility Logdump to examine the
contents of the trail files.
We then find the RBA (Relative Byte Address) for the second insert (ID=2) and will use that
RBA to tell the Replicat process to start processing not from the beginning of the trail but from a
point in the trail file indicated by the RBA value which we will provide to the ALTER
REPLICAT command.
We navigate through the trail file using the ‘n’ command until we find the record where the
ID=2.
We can see the first INSERT, then the UPDATE and then the DELETE operation. We then see
the second INSERT which we are interested in.
Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
Logdump 45 >n
___________________________________________________________________
Hdr-Ind : E (x45) Partition : . (x04)
UndoFlag : . (x00) BeforeAfter: A (x41)
RecLength : 29 (x001d) IO Time : 2012/07/21 04:48:15.066.791
IOType : 5 (x05) OrigNode : 255 (xff)
TransInd : . (x03) FormatType : R (x52)
SyskeyLen : 0 (x00) Incomplete : . (x00)
AuditRBA : 401 AuditPos : 32627632
Continued : N (x00) RecCount : 1 (x01)
Logdump 46 >n
___________________________________________________________________
Hdr-Ind : E (x45) Partition : . (x04)
UndoFlag : . (x00) BeforeAfter: A (x41)
RecLength : 28 (x001c) IO Time : 2012/07/21 04:50:37.094.598
IOType : 15 (x0f) OrigNode : 255 (xff)
TransInd : . (x03) FormatType : R (x52)
SyskeyLen : 0 (x00) Incomplete : . (x00)
AuditRBA : 401 AuditPos : 33013776
Continued : N (x00) RecCount : 1 (x01)
Logdump 47 >n
___________________________________________________________________
Hdr-Ind : E (x45) Partition : . (x04)
UndoFlag : . (x00) BeforeAfter: B (x42)
RecLength : 9 (x0009) IO Time : 2012/07/21 04:51:00.119.007
IOType : 3 (x03) OrigNode : 255 (xff)
TransInd : . (x03) FormatType : R (x52)
SyskeyLen : 0 (x00) Incomplete : . (x00)
AuditRBA : 401 AuditPos : 33041936
Continued : N (x00) RecCount : 1 (x01)
Logdump 48 >n
___________________________________________________________________
Hdr-Ind : E (x45) Partition : . (x04)
UndoFlag : . (x00) BeforeAfter: A (x41)
RecLength : 29 (x001d) IO Time : 2012/07/21 04:54:12.124.542
IOType : 5 (x05) OrigNode : 255 (xff)
TransInd : . (x03) FormatType : R (x52)
SyskeyLen : 0 (x00) Incomplete : . (x00)
AuditRBA : 401 AuditPos : 33273872
Continued : N (x00) RecCount : 1 (x01)
The Replicat process which has abended, is now altered to start at a specific RBA and then
restarted.
We use the ALTER REPLICAT testrep EXTRBA 1634 command to reposition the replicat
process to start reading records from a specific position in the trail file.
We now see that the replicat has started running and has processed the second insert statement.
SQL> select * from mytab;
ID COMMENTS
———- ——————–
1 INSERTED row
2 INSERTED row
Statistics now show 2 insert operations – note no deletes and updates processed ….