Schema Compare for Oracle 6

Examples - using the command line

This page provides some simple examples of how you can use the Schema Compare for Oracle command line interface.

The command line interface for Schema Compare for Oracle is a separate program called SCO.exe (or SCO32.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\Schema Compare for Oracle 6

For more information on the switches you can use with the Schema Compare for Oracle command line, see Command line switches.

Deploying schema changes with an existing project

To deploy schema changes from a project saved as WidgetDatabases using the command line:

sco /project:"C:\Schema Compare for Oracle\Projects\WidgetDatabases.ocp" /deploy

The following are used for the comparison and deployment:

  • objects selected for comparison when you saved the project
  • options saved in 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 Schema Compare for Oracle user interface.

Creating a deployment script to run later

To create a deployment script from a project saved as WidgetDatabases:

sco /project:"C:\Schema Compare for Oracle\Projects\WidgetDatabases.ocp" /scriptfile:"C:\Deployment Scripts\Script.sql"
If a file with the same name already exists in the location you specify, it will be overwritten.

Creating a simple HTML report of comparison results

To create a simple HTML report of the differences between schemas in the WidgetDatabases project using the command line:

sco /project:"C:\Schema Compare for Oracle\Projects\WidgetDatabases.ocp" /report:"C:\Reports\WidgetReport.html" /reporttype:Simple /reportselectedobjects

Only objects selected in the project will be included in the report.

To include all objects, remove /reportselectedobjects from the command.

If a file with the same name already exists in the location you specify, it will be overwritten.


Scheduling a comparison

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

The following example compares schemas selected in the WidgetDatabases project, and updates log_file.txt with the results:

  1. Create the script:

    sco /project:"C:\Schema Compare for Oracle\Projects\WidgetDatabases.ocp" >> C:\log_file.txt
  2. Save the script as a .bat file. You specify the .bat file as the program to run from within the Scheduled Task wizard by browsing 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.

Schema name in curly brackets in not case sensitive unless you provide it in single quotes (see examples below):

Example 1:
sco /source:user/pass@TEST{'SCHEMA_a'} /target:user/pass@TEST{'SCHEMA_a'}
Example 2:
sco /source:user/pass@TEST{schema_a,'SCHEMA_b'} /target:user/pass@TEST{schema_a,'SCHEMA_b'}

Creating a scripts folder

sco /source System/pass@TEST{SCHEMA_A} /target MyScriptsFolder /deploy
sco /source System/pass@TEST{SCHEMA_A} /scriptsfolder MyScriptsFolder

Comparing schemas

sco /project MyProject.ocp
sco /source System/pass@TEST{SCHEMA_A} /target System/pass@my.host.com/PROD{SCHEMA_A}
sco /source c:\SnapshotFile.snp{SCHEMA_A} /target System/pass@PROD{SCHEMA_A}
sco /source c:\ScriptsFolder{SCHEMA_A} /target System/pass@PROD{SCHEMA_A}

Comparing schemas, ignoring constraint names and storage clauses

sco /source System/pass@TEST{SCHEMA_A} /target System/pass@PROD{SCHEMA_A} /ignore constraintnames /ignore storage

Creating a deployment script, including script header and set define off

sco /source System/pass@TEST{SCHEMA_A} /target System/pass@PROD{SCHEMA_A} 
/scriptfile MyScript.sql /behavior scriptheader /behavior defineoff

Creating a snapshot

sco /project MyProject.ocp /snapshot1 SourceSnapshot.onp /snapshot2 TargetSnapshot.onp
sco /source System/pass@TEST{SCHEMA_A} /target SourceSnapshot.onp /deploy
sco /source System/pass@TEST{SCHEMA_A} /snapshot SourceSnapshot.onp

Didn't find what you were looking for?