Search code examples
databasedb2replication

Foreign key Constraints issue in DB2 SQL replication


While implementing DB2 SQL replication we came to know that apply program was not able to judge the foreign key dependency while applying the changes in target database hence before inserting the data in target table with primary key it was trying to insert the data in table with foreign key.

The consequences were failures of insert operation for some records in the tables with foreign key applied on them.

As a solution we try to include these tables each in different subsets with applied script scheduled each individually for this set. But still as the scripts are concurrently running we were facing same issue.

Is there any solution for this problem or we need to remove the foreign keys and perform the implement the replication.


Solution

  • Since your constraints are supposedly enforced on the source database, you can safely set the foreign key constraints on the destination to NOT ENFORCED, which should eliminate the constraint violation errors. Since you did not provide your DB2 platform and version, you'll have to look up the correct syntax of the ALTER TABLE statement in the appropriate manual yourself.