使用时如何区分数据库顺序 [英] How do I differentiate between databases when using e.g. sequence
问题描述
我刚刚开始使用 Liquibase ,并开始研究该问题以区分不同数据库的功能.
I just started using Liquibase and stumpled upon the problem to differentiate between the capabilities of different databases.
我们希望支持多个数据库(Oracle,MySQL,Derby-仅举三例).
We would like to support multiple databases (Oracle, MySQL, Derby - to name three).
所有功能都有不同.具体来说,Oracle支持sequences
,而MySQL和Derby不支持.
The all have different capabilities. In specific Oracle supports sequences
whereas MySQL and Derby do not.
当我让休眠生成DDL时,我可以选择不同的方言,当使用Oracle时它将考虑这些不同的功能并生成Sequencer
,而在使用Derby或MySQL时使用普通表(用于ID生成).
When I let hibernate generate the DDL I can choose different dialects and it will consider these different capabilities and generate a Sequencer
when using Oracle and use a plain table (for ID-generation) when using Derby or MySQL.
现在,我知道我可以通过在dbms
属性中指定'oracle
'来约束变更集.但是,我该如何为其他数据库做普通表解决方案呢? dbms
似乎没有"not oracle"属性.
Now, I know I can constraint changesets by specifying 'oracle
' in the dbms
attribute. But then how can I do the plain table solution for the other databases? There does not seem to be a 'not oracle' attribute for dbms
.
其他人如何处理呢? (我在liquibase页面或论坛上都找不到有关它的任何信息.)
How does anyone else handle this? (I could not find anything about it on the liquibase pages nor on the forum.)
推荐答案
尝试使用前提条件在changset上.支持布尔运算.
Try using a precondition on the changset. Boolean operations are supported.
例如
<preConditions onFail="CONTINUE">
<or>
<dbms type="oracle" />
<dbms type="mysql" />
</or>
</preConditions>
这篇关于使用时如何区分数据库顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!