【问题标题】:how to load sequence currvalue and incremenBy from database using liquibase?如何使用 liquibase 从数据库中加载序列 currvalue 和 incremenBy?
【发布时间】:2020-07-25 09:12:32
【问题描述】:

我正在尝试使用数据库“Oracle”和“Postgres”中的 liquibase 更改序列

获取序列 current_value 和 incrementBy 并设置为 minvalue = current_value + incrementBy 并且开始 = current_value + incrementBy。 以下是变更集示例。

<changeSet  author="liquibase-docs"  id="dropSequence-exampl3e">  
    <alterSequence  incrementBy="80" startValue="(select last_value from frm_main.R_CBA_CHGBK_DTL_IDS)+(example_id_seq.incrementBy)" 
            minValue="(select last_value from frm_main.R_CBA_CHGBK_DTL_IDS)+(example_id_seq.incrementBy)"
            ordered="false" sequenceName="example_id_seq" />
</changeSet>

如何从数据库中获取序列 current_value 和 incrementBy 值?
是否可以使用 liquibase?
我们只需要使用 liquibase 来解决上述问题。
我们是否有可能使用 liquibase 和 hibernate 实现上述目标?

提前致谢。

【问题讨论】:

    标签: liquibase liquibase-hibernate


    【解决方案1】:

    可能不是最佳解决方案,但是,您可以在 sql 块中运行特定于数据库的查询来实现您的目标:

    <changeSet author="foo" id="1" dbms="postgresql">
        <comment>Alter table</comment>
        <sql>
            ALTER SEQUENCE ...
        </sql>
    </changeSet>
    

    然后类似于 oracle。

    【讨论】:

      猜你喜欢
      • 2011-06-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多