Steve Donie
Principal Software Engineer
Datical, Inc. http://www.datical.com/
I need to convert the structure of PostgreSQL databases to Oracle. In PostgreSQL, I have a postgres database with data. In Oracle I have a blank database in which I want to write postgres database which in PostgreSQL.
In fact, I do not need the data, only the structure (relationships).
For this I use Liquibase. I get the changelog from PostgreSQL with the command:
After this I try to create objects in the Oracle database:
Does not work: ORA-00902
Here is a fragment of postgresql_changelog.xml:
I also generate a pure SQL- file:
Here is a fragment of update.sql:
I would like to generate the file, in which all data types correspond to the target database, ie that I want to create. I can write a simple parser that replace data types, but it is not the right solution - can be many database.
It possible to generate XML/ SQL output with data types of target database?
Or maybe there is an option that allow to generate output with "abstract" data types? Ie with the data types that are not in the real databases, for example, instead of INT8 - Integer, etc.
I would be very grateful for the information. Thanks to all.
Here is a fragment of postgresql_changelog.xml:
Now I want to create the same objects and the same relationships in another database (Oracle):
But it does not work: ORA-00902
It is possible to get changelog from one database and update
another database in different RDBMS server from this changelog? I need
to get automatic data type conversion.
Actually, it is necessary to manually correct the data types in the generated file. Data types are not converted automatically.
For example:
After that execute the command:
The structure will be generated on the target database. Is similarly possible migrate the data (option --diffTypes = "data").
But, really, can be used "abstract" data types, as write in the documentation: Liquibase, Column tag
To help make scripts database-independent, the following “generic” data types will be converted to the correct database implementation: BOOLEAN CURRENCY UUID CLOB BLOB DATE DATETIME TIME BIGINT
Also, specifying a java.sql.Types.* type will be converted to the correct type as well. If needed, precision can be included. Here are some examples: java.sql.Types.TIMESTAMPjava.sql.Types.VARCHAR(255)
And possible to make the copy of structure without DDL (and data without DML).
will
throw the following error during execution: Incorrect
table definition; there can be only one auto column and it must be
defined as a key
The reason is that liquibase runs each of the elements one at a time. if the <createIndex > would have run with the <createTable> change, the error wouldn't have been thrown.
(also, FYI, I couldn't find a way to open a JIRA ticket in https://liquibase.jira.com/ - it didn't allow me to create a user using any of my email addresses saying my domain is not allowed)