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

PostgreSQL (type,id)唯一约束失效:存在重复行问题求助

PostgreSQL唯一约束存在但表中有重复数据问题

我有一张名为accounts_coin的表,在(type, id)字段上设置了唯一约束,但表中仍存在两行(type, id)值完全相同的数据。

相关信息

  • PostgreSQL服务器版本:postgres (PostgreSQL) 15.6 (Ubuntu 15.6-1.pgdg20.04+1)
  • 两周前使用pg_upgrade将PostgreSQL版本从9.4升级到15.6,推测可能是升级导致的问题,但不知如何进一步排查。

测试操作及结果

尝试插入另一条具有相同唯一键值的记录,结果如预期报错:

account=# insert into accounts_coin values ('UchihaWind', 2, 1, 0, 0, 1716860624);
ERROR:  duplicate key value violates unique constraint "accounts_coin_type_id_key"
DETAIL:  Key (type, id)=(2, UchihaWind) already exists.

恳请各位提供帮助。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.23 03:33:09