从Java代码生成SQLite数据库方案

时间:2017-06-08 09:48:07

标签: jooq jooq-sbt-plugin

有没有办法使用JOOQ从Java代码生成SQLite数据库模型?

1 个答案:

答案 0 :(得分:1)

您可以使用DSLContext.ddl() API生成CREATE TABLE ..ALTER TABLE .. ADD CONSTRAINT ..等DDL语句,例如:

// SCHEMA is the generated schema that contains a reference to all generated tables
Queries ddl =
DSL.using(configuration)
   .ddl(SCHEMA);

for (Query query : ddl.queries()) {
    System.out.println(query);
}

这里有记录: https://www.jooq.org/doc/latest/manual/sql-building/ddl-statements/generating-ddl/