Compares a source database to a target database and generates the differences as SQL statements.

COMPARE DATABASE <SourceDatabaseName>
TO <TargetDatabaseName>

Use this statement to compare a database to another database, generating the minimal difference between the two databases as CREATE, ALTER, and DROP SQL statements. These statements are generated into the SchemaDifference table in the system Information schema of the source database.

If not specified, the statement terminator character defaults to the exclamation character ('!'). If an object requires multiple statements for creating, altering, or dropping sub-objects (such as indexes/triggers for tables), then the statement terminator character will be used for separating the multiple statements in the AlterSQL CLOB column of the SchemaDifference table.

Information Every time this statement is executed, any existing information in the SchemaDifference table for the source database will be deleted and replaced with the results of the current statement execution.

-- This example compares the Accounting2012
-- database to the Accounting2013 database

COMPARE DATABASE Accounting2012 TO Accounting2013

Required Privileges
The current user must be granted the SELECT privilege on the both the source and target databases in order to execute this statement. Please see the User Security topic for more information.

SQL 2003 Standard Deviations
This statement deviates from the SQL 2003 standard in the following ways:

ExtensionThis SQL statement is an ElevateDB extension.