我正在嘗試使用這樣的請求向 Postgresql 添加一個條目
insert into customer (id, email, name, number_telephone) VALUES (public.hibernate_sequence_customer.nextval, '[email protected]' , 'Henry', '89132547898');
, 但 flyway 拋出錯誤
Error: table "hibernate_sequence_customer" is missing in the FROM clause
在專案結構中, 在此處輸入影像描述
uj5u.com熱心網友回復:
序列的下一個值通過訪問nextval('public.hibernate_sequence_customer'),而不是點符號。
insert into customer (
id,
email,
name,
number_telephone)
VALUES (
nextval('public.hibernate_sequence_customer'),
'[email protected]' ,
'Henry',
'89132547898');
但是如果您將id列定義為serial,則根本不需要呼叫序列。
create table customer (
id serial primary key,
email text,
name text,
number_telephone text);
只需在您的insert:
insert into customer (
email,
name,
number_telephone)
VALUES (
'[email protected]' ,
'Henry',
'89132547898');
如果您稍后需要參考負責該id列的序列- 例如獲取其當前值 - 您可以使用currval(pg_get_serial_sequence('customer','id')).
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/373295.html
標籤:PostgreSQL的 弹簧靴 飞行路线
上一篇:使用Springboot框架時無法在Mybatis中設定映射引數
下一篇:帶有可選引數請求的微服務通信
