Preparing Tables for Processing
The following table attributes must be addressed in an Oracle GoldenGate environment for PostgreSQL.
Disabling Triggers and Cascade Constraints on the Target
If Oracle GoldenGate is configured to capture DML operations from source tables that occur due to trigger operations or cascade constraints, then disable the triggers and cascade delete and cascade update constraints on the target tables.
emp_src
and
salary_src
and the target tables are emp_targ
and salary_targ
-
A delete is issued for
emp_src
. -
It cascades a delete to
salary_src
. -
Oracle GoldenGate sends both deletes to the target.
-
The parent delete arrives first and is applied to
emp_targ
. -
The parent delete cascades a delete to
salary_targ
. -
The cascaded delete from
salary_src
is applied tosalary_targ
. -
The row cannot be located because it was already deleted in step 5.
In the Replicat MAP
statements, map the source tables to appropriate
targets, and map the child tables that the source tables reference with triggers or
foreign-key cascade constraints. Triggered and cascaded child operations must be
mapped to appropriate targets to preserve data integrity. Include the same parent
and child source tables in the Extract TABLE
parameters.
Ensuring Row Uniqueness for Tables
Oracle GoldenGate requires some form of unique row identifier on the source and target tables to locate the correct target rows for replicated updates and deletes.
KEYCOLS
clause is used in the
TABLE
or MAP
statement, Oracle GoldenGate selects
a row identifier to use in the following order of priority:
-
Primary key
-
First unique key alphanumerically that does not contain a timestamp or non-materialized computed column.
-
If none of the preceding key types exist (even though there might be other types of keys defined on the table) Oracle GoldenGate constructs a pseudo key of all columns that the database allows to be used in a unique key, excluding those that are not supported by Oracle GoldenGate in a key or those that are excluded from the Oracle GoldenGate configuration. For PostgreSQL LOB types such as
text
,xml
,bytea
,char
,varchar
, Oracle GoldenGate supports these columns as a primary key in source or target tables up to a length of 8191 bytes.Note:
If there are other, non-usable keys on a table or if there are no keys at all on the table, Oracle GoldenGate logs an appropriate message to the report file. Constructing a key from all of the columns impedes the performance of Oracle GoldenGate on the source system. On the target, this key causes Replicat to use a larger, less efficientWHERE
clause.For tables that have no uniqueness and have repeat rows with the same values, Replicat will Abend on update and delete operations for these rows.
-
If a table does not have an appropriate key, or if you prefer that the existing key(s) are not used, you can define a substitute key, if the table has columns that always contain unique values. You define this substitute key by including a
KEYCOLS
clause within the ExtractTABLE
parameter and the ReplicatMAP
parameter. The specified key will override any existing primary or unique key that Oracle GoldenGate finds. See TABLE | MAP in Reference for Oracle GoldenGate.
Enabling Table-Level Supplemental Logging
Enabling Supplemental logging is a process in which Oracle GoldenGate sets source database table level logging to support change data capture of source DML operations, and depending on the level of logging, to include additional, unchanged columns which would be needed in cases such as bi-directional replication with conflict detection and resolution configured.
There are four levels of table level logging in PostgreSQL, which equate to the
REPLICA IDENTITY
setting of a table, and those include
NOTHING
, USING INDEX
, DEFAULT
, and
FULL
.
Oracle GoldenGate requires FULL
logging for use cases that
require uncompressed trail records and Conflict Detection and Resolution, but in cases where
tables have a Primary Key or Unique Index whose changes are being replicated in a simple
uni-directional configuration or where full before-images or uncompressed records are not
needed, then the DEFAULT
level is acceptable. NOTHING
and
USING INDEX
logging levels are not supported by Oracle GoldenGate and
cannot be set with ADD TRANDATA
.
ADD TRANDATA
from
GGSCI.GGSCI> DBLOGIN SOURCEDB dsn_name USERIDALIAS alias_name
GGSCI> ADD TRANDATA schema.tablename ALLCOLS
Note:
For tables that have a primary key or unique index, theALLCOLS
option is
required in order to set FULL
logging for the table, otherwise
DEFAULT
logging is set.
FULL
logging is always set for tables without a primary key or unique index,
regardless of whether ALLCOLS
is specified or not.
GGSCI> INFO TRANDATA schema.tablename