Previous Topic

Next Topic

Book Contents

Book Index

Data Compare

The Data Compare tool allows you to compare the data between two tables, views or queries. It can be invoked from the Database Explorer by clicking on Tools > Compare Data, or the Compare Data icon.

The Data Compare tool is part of the Extended Edition of AQT, which is a separately purchasable component of AQT. If you have not purchased the Extended Edition you can still use Data Compare, however you will be limited to comparing 100 rows.

Data Compare has the following features:

Data Compare

Specifying the Tables or Queries

You use the Compare and Compare To boxes to specify the tables or queries to be compared. Click on the three-dots button to select a table, or type the table name into the Table text-box.

Unique Key

In order to compare tables, the tables must have a column (or set of columns) that uniquely identifies each row in the tables. This is used to match the rows from the two tables. AQT will get this key for you automatically if your table has a primary key, unique key, or user-defined key. Otherwise you will need to specify this.

If the table doesn't have a primary key, or you are comparing a query, you can specify which columns comprise the unique key in two ways:

If you are comparing a query, the query must return the data in the order of the unique key columns (eg. must have an order by keycol1, keycol2 clause).

Filter Rows

The Filter Rows is used to apply a search condition to your table. You would use this to exclude rows that you do not wish to be included in the Compare.

Code this as a Where clause but without the Where keyword. Examples:

cust_code is not null

order_number > 0 and order_date > '1998-02-05'

Specifying the Columns

You can specify which columns in your tables are to be compared by clicking on the Columns tab. This shows you the columns in your tables / queries.

Generate Script

AQT can generate a script to resynchronize the contents of the two tables. In the Generate Script box you can specify whether:

File specifies the name of the script file that AQT will generate.

Once the compare has been run, you can view the script file by clicking on the View Script button. You can run the script file by clicking on the Run Script button.

If you are comparing queries instead of tables, you cannot generate a script. AQT can generate SQL for inserting / deleting / updating a table, but not for updating a query.

Note: when generating Update and Insert statements, AQT will only include the columns which are being compared. If you exclude a column from the compare, it will not be included in the Update / Insert. Because no matching column has been specified, AQT is unable to know what value to use for the Update / Insert.

Generate the Update / Insert / Delete statements to separate files

By default, the resynchronization script will have all the SQL statements in a single file.

Sometimes it can be useful to have the Update / Insert / Delete statements in separate files - this is can be needed if you are resynchronizing a set of tables that have foreign keys defined between them. In this case the update / inserts / deletes for the various tables have to be run in a particular order.

To do this, go to the More Options tab and click on Generate Updates, Inserts, Deletes to separate files. AQT will write the update, insert, delete statements to the specified files, as well as to the "main" resynchronization script file.

Report File

AQT can generate a report file giving a text-based report of the Data Compare. The report file is mainly useful when running the Data Compare in batch.

Other Options

Order-By Mask

This option appears on the More Options tab. It is discussed in the section Collation Order Problem.

Running the Compare

To run the Compare click on the Compare button. To stop the compare, click on Abort.

Once the compare has completed, you will be shown the compare results on the Results tab.

Saving / Retrieving Compare Specifications

You can save or retrieve your options for a data compare. This is done with File > Save Compare Options and File > Open Compare Options.

Other notes