Cross-database constraints and loading databases

If you use the references constraint of create table or alter database to reference tables across databases, you may encounter problems when you try to load a dump of one of these databases.

Cross-database constraints can become inconsistent if you:

If you do not load, cross-database constraints can become inconsistent.

To remedy this problem:

  1. Put both databases in single-user mode.

  2. Drop the inconsistent referential constraint.

  3. Check the data consistency with a query such as:

    select foreign_key_col from table1
    where foreign_key not in
    (select primary_key_col from otherdb..othertable)
    
  4. Fix any data inconsistency problems.

  5. Re-create the constraint.