Switch to: V10V9V8V7V6V5

SQLDiff Renaming Objects

For example, you need to synchronize two databases using sql diff. A source database contains two tables - “Table1” and “Table2”. A destination database contains three tables “Table1”, “Table2_Renamed” and “Table3”. A Table2_Renamed was got from Table2 by renaming. To get synchronization script with rename query for Table2 you should use one of the two scenario of sql diff :

  • Compare databases, using a Object_ID, like comparing key.
  • Compare databases, using a Object_Name, like comparing key, and after that configure renamed object.

Way 1: Automatically Renaming

Step 1: Select Databases

Run SQLDiff. Select source and target databases.

Step 2: Change Parameters of Comparing

In the page of parameters - change option Key For Comparing to Object ID.

Step 3: Make Comparing

Now you can compare databases. For this - go through SQLDiff wizard to the end, and press Finish button.

Step 4: Preview Result

Now you can see the result of comparing

Script of synchronization contains query for creating Table3, and renaming Table2 to Table2_Renamed. This is exactly what we wanted.

Way 2: Manual Renaming

Step 1: Select Databases

Run SQLDiff. Select source and target databases.

Step 2: Make Comparing

Now you should compare databases without any changes in the properties of comparing. For this - go through SQLDiff wizard to the end, and press “Finish” button.

Step 3: Preview Result

Now you can see the result of comparison:

The script of synchronization contains queries for creating tables Table3 and Table2_Renamed, and to drop Table2.

But this is wrong result, because we have to rename table instead drop it and loose all its data.

To solve this situation you should click at the last column of the action for Table2, where the symbol ”…”. In the menu - select “Rename To…” and choose Table2_Renamed.

Now we can see correct result of SQL Difference.

Discard Renaming

To discard renaming you should click at the last column of the action for Table2_Renamed, where the symbol ”…”. In the menu - select “Discard Renaming”.