Use the Compare Data wizard to compare data between tables that are within different schemas or iin different databases, such as the same tables in production and test environments. Toad then generates a synchronization script that you can run as-is, save as a file, or send to the Editor to be refined.
To run the Compare Data wizard
- From the Database menu, select Compare | Data.
- Complete the Choose Tables and Select Columns pages (see the following descriptions).
- Click Next to run the comparison. Toad displays the results of the comparison and then provides options for generating the comparison script. See Results Output.
Choose Tables page
Use the tabs of this page to specify the comparison objects and options.
Tables tab
- Select the source and target database connections and schemas that contain the tables that you want to compare.
-
Specify database link options as needed:
- If your first data source is remote, select an existing DB Link.
- If your first data source is local, leave this box blank.
- Select the object type, owner, and objects name. Click the > arrow to copy the name to the Target side if the source and target selections are the same.
- (Optional) Add a WHERE clause to further refine the object selection. Click the > arrow to copy the clause to the Target side.
- (Optional) To make the current target the source (switch sides) click
(Switch Source and Target).
Options tab
- Click Optimizer Hints to specify the type of hint to use. When parallel hint is selected, you can specify the degree of parallelism.
-
(Optional) Click Sort Area Size to change the current sort area size and the one that Toad goes back to when the window closes. This only affects comparisons that do not go through a Database Link.
Select Columns page
Select the columns that you want to include in the comparison. Toad notifies you of discrepancies it finds:
- it does not detect a key column
- a column cannot be compared because it does not exist in both tables
- the data types cannot be compared
Toad handles primary keys as follows:
- If a table has a primary key, Toad finds it automatically and identifies it under the PK column in the grid.
- If no primary key is found, you can select column(s) under the PK column that can be used as a primary key.
- With the primary key identified (automatically or manually), Toad will use those columns to identify whether a row is in both tables, but with differences.
- If no primary key is identified, Toad has no way of identifying a row except by using all of the columns, and rows are either matches, or in one table, or the other.
If structural differences cannot be resolved to enable valid comparison, you can compare the objects themselves. Click (Compare Objects) at the bottom of the page.
Results Output
-
Select what you want to do with rows that match: Count them, display them, or ignore them.
Option
Description
Row Count(Match | (Differ)
Displays the total number of rows that were compared.
Match means the number of rows in each table is the same. Differ means there is a difference in the row count between source and target tables.
Source Only and Target Only These tabs have the same format and show the number of rows that exist only on the source and only on the target.
Differences Displays the values of each compared source and target row and highlights differences.
This tab displays:
- Rows from the source dataset in gray
- Rows from the Target dataset in white
- Column values that differ between source and target are highlighted in yellow.
Matches
This result is displayed if you selected Display as the way to handle rows that match. The row values are shown, which reflect their state in both source and target.
-
Do one of the following:
- Click Compare to run the comparison again.
-
Select from Sync options: Synchronize the data between the tables, send the synchronization script to the Editor, or save the synchronization script to a file. If you choose to synchronize the data, you are prompted whether to commit or roll back the changes.
Notes:
- If you simply close the synchronize window, rather than selecting Commit or Rollback, Toad displays these icons for you to make that selection:
.
- Toad does an automatic savepoint at the beginning of synchronization. If user cancels the synchronization, Toad rolls back to the savepoint.
- If you simply close the synchronize window, rather than selecting Commit or Rollback, Toad displays these icons for you to make that selection: