Liquibase DB Independent Insert语句

时间:2012-07-05 23:44:13

标签: mysql database oracle liquibase

我有使用Liquibase定义的Oracle / MySql / PostgreSql模式。我有一些插入语句。现在我想编写支持所有三个DB的<insert>标记,这样如果它是MySql,它将使用自动增量功能和Oracle的序列。我可以在不重复<insert>标记的情况下实现此目的吗?

1 个答案:

答案 0 :(得分:0)

实际上我认为这比你想象的更痛苦。我相信你必须用不同的变更集来做到这一点。请参阅How do I differentiate between databases when using e.g. sequence

所以你会:

<changeSet id="x" author="y">
  <preConditions>
    <dbms type="oracle"/>
  </preConditions>
  ...
</changeSet>
<changeSet id="xx" author="y">
  <preConditions>
    <dbms type="mysql"/>
  </preConditions>
  ...
</changeSet>
<changeSet id="xxx" author="y">
  <preConditions>
    <dbms type="postgres"/>
  </preConditions>
  ...
</changeSet>