How to use Liquibase to migrate MS SQL Server to Oracle

by | Jul 20, 2015

I’m a certified SQL Server DBA, a certified Oracle DBA, and I’ve used liquibase before, so I thought that using liquibase to migrate a schema definition from SQL Server to Oracle was going to be trivial. I was surprised at how much work was involved.
Please note that this process does not copy any data, it just copies the empty structures.

  1. I already had liquibase. Liquibase is just a download with no install.
  2. I did need to configure liquibase. I keep one .properties file for each of my databases. They are:
    1. MS SQL
      classpath=C:\Program Files\Microsoft JDBC Driver 4.1 for SQL Server\sqljdbc_4.1\enu\sqljdbc41.jar
      [/code] Notice that:

      1. I’ve downloaded and unzipped the Microsoft JDBC
      2. The double slashes in the classpath
      3. the JDBC URL is my SQL Server, on which I am using the default instance.
      4. I’ve used SQL Server authentication, rather than windows authentication
    2. Oracle
      [code] driver: oracle.jdbc.OracleDriver
      classpath: C:\oracle\instantclient_12_1\ojdbc7.jar
      url: jdbc:oracle:thin:@YourDBHostname:1521:ORCL
      logFile=C:\Program Files\liquibase-3.3.5-bin\liquibase.log
      [/code] Notice that:

      1. I’ve also downloaded and installed the instant client for Oracle.
      2. Again the double slashes in the classpath.
      3. That I’ve kept the same changeLogFile.
      4. That I set the log as you’ll probably need to look through that.
  3. Copy to Then reverse-engineer your database with generateChangeLog.
    [code] liquibase generateChangeLog [/code]
  4. Now comes the step that I wasn’t expecting. The liquibase change log is a lot more database dependent than I was expecting. Before you can apply it to Oracle you’ll need to:
    1. remove Autoincrement from columns
    2. examine the Default values for database specific functions. i.e. USER in Oracle vs current_user() in SQL Server.
    3. Manually convert “user defined” types used for SQL Server columns. Including types that shipped with SQL Server like SYSNAME.
    4. Manually convert DATETIMEOFFSET to DATE or TIMESTAMP as is appropriate.
  5. Now copy over with your file and update your Oracle database.
    [code] liquibase update [/code]
  6. Finally, you’ll need to generate sequences and before-insert-row triggers for the SQL Server identity columns we removed earlier. You can write your own dynamic-SQL generator or just let Freeware Toad do that for you.

This process is far from ideal. I appreciate that this isn’t a core feature of liquibase, just a trick that it doesn’t prevent. I’m inclined to believe that there are other tools that do this task better, I just don’t happen to know of any that are free. It may not be pretty, but liquibase will port your tables from Microsoft SQL Server to Oracle.
We run regular business intelligence courses in both Wellington and Auckland. Find out more here.



  1. How to use Liquibase to migrate MS SQL Server to Oracle – Steven Ensslen - […] Read the rest on on the Optimal BI blog. […]
Submit a Comment

Your email address will not be published. Required fields are marked *