Parse sql script

Hi all,

i want to parse a sql file, which contains for example

“CREATE TABLE [Meeting] ([pkMeeting] INT NOT NULL, [Name] VARCHAR(50), CONSTRAINT [PK_tblMeeting] PRIMARY KEY ([pkMeeting]));” ,

over liquibase in java, so i can use getters for the tablename or columnname(s). Is that possible?

I just found classes like “CreateTableStatement”, but maybe i’m completely wrong with this approach?

The other way round to generate the sql script over liquibase with the “SqlGeneratorFactory” and the “CreateTableChange” with its “ColumnConfigs” and “ConstraintsConfigs” was successful.

I hope someone can help me.

Best regards
K

I think you are asking if Liquibase can parse SQL - the answer is no, it cannot.

It is able to generate SQL (customized for each of the different database platforms it supports) starting from a more general ‘language’ (the changelog, which can be in XML, YAML, or JSON), but it does not currently have support for going the other way.

There is a ‘round-about’ way of getting there, which is to apply the SQL to a database using whatever tools that database provides, and then you can use Liquibase’s 'diffChangeLog" command to generate a changelog, which is something that could be loaded into Liquibase’s “Database Schema Model”, where you could do things like use java to enumerate all the database objects, etc.

Steve Donie
Principal Software Engineer
Datical, Inc. http://www.datical.com/