You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PostgreSQL中使用Flyway迁移时出现hibernate_sequence_customer表缺失错误

问题原因
  • 你所用的序列取值语法属于Oracle的语法规范,PostgreSQL 不支持 序列名.nextval 这种调用形式,必须通过内置的 nextval() 函数获取序列的下一个值。
  • 报错提到缺失FROM子句,是因为PostgreSQL将 public.hibernate_sequence_customer.nextval 识别为「访问public.hibernate_sequence_customer表的nextval字段」,你要读取该字段却没有在FROM子句中指定对应的表,因此触发了报错。
修复方案

将你的INSERT语句调整为PostgreSQL兼容的写法即可:

insert into customer (id, email, name, number_telephone) 
VALUES (nextval('public.hibernate_sequence_customer'), 'abc@jar.ru' , 'Henry', '89132547898');
额外注意事项
  • 如果customer表的id字段已经将该序列设为自增默认值,你可以直接省略id字段的赋值,数据库会自动生成主键值,写法更简洁:
insert into customer (email, name, number_telephone) 
VALUES ('abc@jar.ru' , 'Henry', '89132547898');
  • 请确认你的Flyway迁移脚本执行顺序,确保调用该序列之前,已经有更早版本的迁移脚本完成了public.hibernate_sequence_customer序列的创建,避免后续出现序列不存在的报错。

内容的提问来源于stack exchange,提问作者Restisx

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.23 14:36:01