Data Compare for Oracle 6

Command line examples

The command line interface for Data Compare for Oracle is a separate program called DCO.exe (or DCO32.exe for use with the 32-bit Oracle client on 64-bit machines). It is installed in the same location as the graphical tool. This is typically C:\Program Files\Red Gate\Data Compare for Oracle 2

You can now use the command line to set source and target data sources to compare.

Getting a comparison summary

To get a comparison summary from a project saved as Example.dco using the command line:

dco /project:"C:\Data Compare for Oracle\Projects\Example.dco"

The project option settings saved in the project are used for the comparison.

Deploying data changes

To deploy data changes from a project saved as Example.dco using the command line:

dco /project:"C:\Data Compare for Oracle\Projects\Example.dco" /deploy

The following are used for the comparison and deployment:

  • tables selected for comparison when you saved the project
  • options saved for the project

    If you want to include or exclude objects from an existing project, or edit options for an existing project, you must modify your selection using the Data Compare for Oracle user interface.

Deploying data to an empty schema

To deploy data to an empty using the command line you need to provide source and target (target as script folder should contain a schema generated by Schema Compare for Oracle):

dco /source:user/pass@host/service{SOURCESCHEMA}  /target:"C:\RedGate"{TARGETSCHEMA} /deploy

If you want to deploy just data from Source you can use:

dco /source:user/pass@host/service{SOURCESCHEMA} /target:"C:\RedGate"{TARGETSCHEMA} /deploy /comparison:includeSourceTables

Creating a deployment script to run later

To create a deployment script from a project saved as Example.dco using the command line:

dco /project:"C:\Data Compare for Oracle\Projects\Example.dco" /scriptfile:"C:\Deployment Scripts\Script.sql"

This example requires C:\Deployment Scripts to be an existing folder.

If there is already a file of the same name in the location you specify, it will be overwritten.

Creating a CSV report of comparison results

To create a CSV report of the differences between the tables in the Example.dco project using the command line:

dco /project:"C:\Data Compare for Oracle\Projects\Example.dco" /report:"C:\Reports"

The report will be saved with the same name as the project.

If a file with the same name already exists, the report won't be created.

Scheduling a comparison

You can use the Windows task scheduler to schedule a comparison by creating a script to run the comparison.

This example compares tables selected in the Example.dco project and updates log_file.txt with the results:

  1. Create the script:

    dco /project:"C:\Data Compare for Oracle\Projects\Example.dco" >> C:\log_file.txt
  2. Save the script as a .bat file.
    To specify the .bat file as the program to run from the Scheduled Task wizard, browse to it.
The example uses MS-DOS batch scripting, a basic scripting language supported in all versions of Windows. If you want, you could use VBScript, JScript, PHP, Perl, Python or other scripting language.

Specifying table and view names using regular expressions

With the following switches, you can specify table or view names using regular expressions:

/comparisonkeys:<regular expression>:<index name or comma-separated columns>

/exclude:<regular expression>

/excludecolumns:<regular expression>:<comma-separated column names>

/include:<regular expression>

/includecolumns:<regular expression>:<comma-separated column names>

In this example, you want to compare two schemas, SOURCESCHEMA and TARGETSCHEMA. The schemas contain the following tables:

  • Product
  • Supplier
  • ProductCategory
  • SpecialOffer
  • Customer
  • Order
  • Invoice

You want to include the tables Product, ProductCategory, Customer, and Order in your comparison.

  1. Use /source and /target to specify the source and target schemas to compare.
  2. Use /include to specify the list of tables to include.
    • Use the pipe character (|) to separate the table or view names. This is interpreted in a regular expression as a logical OR.
    • Use the caret character (^) to prevent the operating system shell from interpreting reserved characters (eg the pipe character) as logical operators. If you need to use ^ itself as part of your regular expression, escape it by using a second ^ character.
    • Put double quotes (") around table or view names for an exact match.

Example

dco /source:user/pass@host/service{SOURCESCHEMA} /target:user/pass@host/service{TARGETSCHEMA} /include:Product^|"Customer"^|"Order"

In the example above:

  • /source:user/pass@host/service{SOURCESCHEMA} specifies that you want to compare the schema SOURCESCHEMA

  • /target:user/pass@host/service{TARGETSCHEMA} specifies that you want to compare the schema TARGETSCHEMA

  • /include:Product^|"Customer"^|"Order" specifies that you want to compare only the tables that have a name that includes the string Product, or a name identical to Customer or Order.

Both the Product and ProductCategory tables are included for comparison, because Product is specified without double quotes. To include Product but not ProductCategory, specify Product with double quotes.

Use .NET standard regular expressions to define the /include and /exclude arguments. For more information on regular expression syntax, see the Microsoft .NET framework documentation.


Didn't find what you were looking for?