You need to disable any database triggers or cascade-delete referential integrity constraints on your target tables.(你需要在目标库禁止触发器或者级联删除)
The reason is to prevent duplicate changes, because GoldenGate is already replicating the
results of the trigger and cascade-delete operations from the source database. If you didn’t disable the
constraints and triggers, GoldenGate would replicate those changes; then the triggers and cascadedelete
constraints would also fire, causing duplicate changes on the target database.
Several methods are available for disabling the triggers and cascade-delete constraints. The first
method is only available for newer Oracle versions and involves adding parameters to the Replicat. The
second method is simply to alter the tables to disable the triggers and constraints and then enable them
when replication is turned off.
Starting with GoldenGate version 11, a new SUPPRESSTRIGGERS option is available as part of the
Replicat DBOPTIONS parameter, to automatically suppress the triggers from firing on the target. You can
use it to avoid having to manually disable the triggers. This option is available for Oracle 10.2.0.5
databases and later, and for Oracle 11.2.0.2 databases and later. To disable constraints, if you have
Oracle 9.2.0.7 database and later, you can use the Replicat parameter DBOPTIONS with the DEFERREFCONST
option to delay checking and enforcement of integrity constraints until the Replicat transaction
commits.
You can also use a SQL script such as the following Oracle database example to automatically
generate your ALTER TABLE enable and disable commands for the cascade-delete constraints and
triggers. Using a script to dynamically generate the commands from the database saves time and
ensures more accuracy. In this example, the script prompts for the schema owner name:
set echo off
set verify off
set pagesize 2000
set linesize 250
set trim on
set heading off
set feedback off
spool &&SCHEMA..disable_cascade_delete_constraints.sql
select 'alter table '||owner||'.'||table_name||
' disable constraint '||constraint_name||';'
from all_constraints
where delete_rule = 'CASCADE'
and owner = '&SCHEMA';
CHAPTER 4 ■ BASIC REPLICATION
58
spool off
spool &SCHEMA..disable_triggers.sql
select 'alter trigger '||owner||'.'||trigger_name||
' disable ;'
from all_triggers
where owner = '&SCHEMA';
spool off
spool &SCHEMA..enable_cascade_delete_constraints.sql
select 'alter table '||owner||'.'||table_name||
' enable constraint '||constraint_name||';'
from all_constraints
where delete_rule = 'CASCADE'
and owner = '&SCHEMA';
spool off
spool &SCHEMA..enable_triggers.sql
select 'alter trigger '||owner||'.'||trigger_name||
' enable;'
from all_triggers
where owner = '&SCHEMA';
spool off
The script generates four spool files, which you can then execute in SQLPLUS to disable and enable
the triggers and cascade-delete constraints.
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/21266384/viewspace-2168293/
,如需转载,请注明出处,否则将追究法律责任。