java - Liquibase:将列更改为 DB2 中的自动增量列(标识)
问题描述
我正在尝试将 BIGINT 列更改为 DB2 中的自动增量列,但我似乎无法找到方法。我试着这样做:
<changeSet id="08.01" author="...">
<addColumn tableName="table_name">
<column name="id" type="bigint">
<constraints nullable="true"/>
</column>
<column name="member_type" type="varchar(100)">
<constraints nullable="true"/>
</column>
</addColumn>
</changeSet>
<changeSet id="08.02" author="...">
<addAutoIncrement tableName="table_name"
columnDataType="bigint"
columnName="id"/>
</changeSet>
当它运行时我得到这个错误:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liquibase' defined in class path resource [org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration$LiquibaseConfiguration.class]: Invocation of init method failed; nested exception is liquibase.exception.MigrationFailedException: Migration failed for change set classpath:db/changelog/08-separation.xml::08.01::author:
Reason: liquibase.exception.DatabaseException: DB2 SQL Error: SQLCODE=-270, SQLSTATE=42997, SQLERRMC=72, DRIVER=4.13.127 [Failed SQL: ALTER TABLE SCHEMATEST.table_name ALTER COLUMN id SET GENERATED BY DEFAULT AS IDENTITY]
at org.springframework.bean
...
...
...
Caused by: liquibase.exception.MigrationFailedException: Migration failed for change set classpath:db/changelog/08separation.xml::08.01::author:
Reason: liquibase.exception.DatabaseException: DB2 SQL Error: SQLCODE=-270, SQLSTATE=42997, SQLERRMC=72, DRIVER=4.13.127 [Failed SQL: ALTER TABLE SCHEMATEST.table_name ALTER COLUMN id SET GENERATED BY DEFAULT AS IDENTITY]
...
...
...
Caused by: com.ibm.db2.jcc.am.SqlSyntaxErrorException: DB2 SQL Error: SQLCODE=-270, SQLSTATE=42997, SQLERRMC=72, DRIVER=4.13.127
解决方案
推荐阅读
- python - 在时间范围内查找现值,熊猫
- google-sheets - 如何在谷歌表格中删除这种表格
- nginx - 为 yii 2 设置 nginx
- django - Django Rest Framework - 当获取模型类型的对象不是 JSON 可序列化时,如何从响应中返回模型的所有信息?
- applescript - 基本 do shell 脚本在 applescript 中给出错误
- google-apps-script - 将电子表格中的多行复制到另一个电子表格
- r - 如何使 actionButton 将 code.R 运行到上传的数据集?
- django - Django-allauth 确认电子邮件消息重定向到不同的 URL
- batch-file - 批处理文件-命令-重命名文件夹的动态输入
- arrays - 如何在 x86 程序集中使用寄存器值作为数组元素偏移量?