Examples - using the command line
Published 26 July 2017
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 3
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"
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.
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:
Create the script:
sco /project:"C:\Schema Compare for Oracle\Projects\WidgetDatabases.ocp" >> C:\log_file.txt
- 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.
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