If you asked me to pick a favorite of these three, I’d HAVE to pick SQLcl, but all make a very compelling case.
Liquibase is an open source project for controlling/managing database updates. We’ve enhanced it for Oracle Database in SQLcl. All of my Liquibase posts can be found here.
OCI Cloud Shell is a Shell prompt built into the web console for Oracle Cloud Infrastructure (OCI).
In a previous post, I talked about running SQLcl in OCI CLoud Shell.
In this post, I want to combine all three to demonstrate something very cool!
Generating SQL files and comparing them
A somewhat recent edition to our ‘generate-schema’ command in SQLcl, is the ability to both put the resulting files in different directories, grouped by object type, AND to generate corresponding SQL files.
By default, the Liquibase command will generate only XML files, all in one directory together.
liquibase generate-schema -split -sql
The ‘-split’ is pretty obvious, and the ‘-sql’ is too, but let’s visit the help topic anyways.
-sql {true|false} Generate a SQL file along with the changelog showing the DDL for the object. This SQL is not intended for anything other than review.
The SQL files won’t be used for updates, but they WILL be available for developers to review and to quickly perform DIFFs to see how their objects are evolving over time.
In most cases, comparing XML side by side isn’t as illustrative as comparing two text-based SQL files.
Once the file has completed, in my CWD, I’ll see my controller.xml file, and a few directories. If I look inside the ‘table’ directory, I see both an XML and SQL file for each table.
Now, in addition to using Cloud Shell’s terminal prompt, I want to use the new ‘Code Editor.’
In a few moments, you’ll now have two panels open in the footer of your browser.
I can now open files, use the file explorer…and do DIFFs!
How to compare files in OCI Code Editor?
- View Explorer
- Navigate your directory structure, find both files, open
- In Open Editors, select file one, choose ‘Select for Compare’
- Select second file, choose ‘Compare with Selected’
And that’s it!
Here’s a better look.