【问题标题】:Unable to insert values in a table using sequence in Liquibase无法使用 Liquibase 中的序列在表中插入值
【发布时间】:2015-11-30 23:50:12
【问题描述】:

我想使用 sequence_name.NEXTVAL 在 liquibase 中自动计算列的值。后端数据库是 postgresql。我尝试使用this link 中所示的“valueComputed”属性。但它不是使用序列计算值,并且列的值在插入时为空。我们如何使用序列自动增加 liquibase 中的列?提前谢谢你的帮助。

我的代码如下:

    <changeSet id="20151020000" author="jhipster">      

    <createSequence cycle="false" incrementBy="1" maxValue="1000"  minValue="50" sequenceName="seq_name" startValue="50"/>

    <createTable tableName="tablename">
                <column name="id" type="bigint" valueComputed ="seq_name.NEXTVAL">
                    <constraints primaryKey="true" nullable="false"/>
                </column>
   </createTable>

【问题讨论】:

    标签: postgresql liquibase jhipster


    【解决方案1】:

    这对我有用:

    <createTable tableName="tablename">
        <column name="id" type="bigint" defaultValueSequenceNext="seq_name">
            <constraints primaryKey="true" nullable="false"/>
        </column>
    </createTable>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-07-27
      • 1970-01-01
      • 1970-01-01
      • 2017-05-09
      • 2020-08-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多