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

PostgreSQL数组列更新报错求解决:将LinkedBookings设为自身Id

解决PostgreSQL数组列更新的语法错误问题

你遇到的语法错误是因为PostgreSQL中不能用{"Id"}这种格式构造数组,正确的数组构造方式有两种,都是无需编写函数的简单方案:

  • 使用ARRAY关键字构造单元素数组:
UPDATE public."Booking" b
SET "LinkedBookings" = ARRAY[b."Id"];
  • 使用数组构造函数array():
UPDATE public."Booking" b
SET "LinkedBookings" = array(b."Id");

这两种写法都会将每一行的LinkedBookings列设置为包含当前行Id的整数数组。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.04 00:00:18