handling autoincremented primary keys and foreign keys

Compares and synchronizes Oracle data

Moderators: eddie davis, richardjm, Michael Christofides, neil.anderson

handling autoincremented primary keys and foreign keys

Postby alias2102 » Tue Sep 10, 2013 10:47 pm

Hi, I was wondering if "Data Compare" handles foreign keys properly during synchronization. Here's what I mean. I have two databases DB1 and DB2. Each database has a table USERS with autoincremented primary key. This key is also present as a foreign key in another table ORGANIZATION in the same database. Both DB1 and DB2 have both tables present. How would Data Compare merge the data from both databases where primary keys are identical?
Let's say I have a USERS record In DB1 with primary key 1 and a USERS record with the same primary key value in DB2. What is going to happen to the primary keys and their corresponding foreign keys after the merge?
alias2102
 
Posts: 1
Joined: Tue Sep 10, 2013 10:36 pm

Postby Michael Christofides » Wed Sep 18, 2013 2:27 pm

Hi, sorry for the delayed response.

What is your desired behavior here? Depending on that you have a couple of options.

If the primary key could be the same for two records that you want to keep, you should set a different comparison key. By default we choose the Primary Key for this, but you can change it, details on how to do so here:
http://documentation.red-gate.com/displ ... to+compare

If, however, the same primary key implies that you only want to overwrite the data in the target machine, simply keeping this row selected in the comparison results when you start the deployment wizard will result in a script which will alter that row.

In either case foreign keys will be respected.

Hopefully that helps, do say if we've misunderstood.

Michael
Michael Christofides
 
Posts: 94
Joined: Wed Apr 20, 2011 6:37 pm
Location: Red Gate Software


Return to Data Compare for Oracle

Who is online

Users browsing this forum: No registered users and 0 guests

cron