【发布时间】:2019-05-29 10:23:35
【问题描述】:
我正在尝试将 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
【问题讨论】:
-
您希望它成为主键吗?
-
是但没必要...