【问题标题】:Change datatype of column in Postgresql更改 Postgresql 中列的数据类型
【发布时间】:2021-07-26 12:46:36
【问题描述】:

我有一个数据库迁移文件 -

create table enqueries(
    id integer primary key ,
    message text not null
    );

我想通过创建另一个迁移文件将“ID”的数据类型更改为 bigserial alter table emi_tncs alter column id type bigserial;,在Java Springboot中,“ID”的生成类型是IDENTITY

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

但这显示错误。 感谢您的帮助。

【问题讨论】:

标签: java spring postgresql


【解决方案1】:

我使用以下查询添加了另一个迁移文件

ALTER TABLE enqueries ALTER COLUMN id
ADD GENERATED BY DEFAULT AS IDENTITY;

它解决了问题。

【讨论】:

    猜你喜欢
    • 2012-12-16
    • 2011-11-02
    • 2021-06-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-12
    • 2021-03-04
    相关资源
    最近更新 更多