为什么我会发生冲突?

时间:2020-09-24 05:10:15

标签: postgresql

我有一个表(test),其中包含以下字段:

id (text)
msg (text)
result (bytea)

其中id被定义为索引

我正在运行以下查询:

insert into test(id, result) 
values ('t1', 't-res')
on conflict (id) do update
set result = 't-res'

但是我得到了:

there is no unique or exclusion constraint matching the on conflict specification
  • 我不明白为什么会发生冲突?
  • 我该如何解决?

1 个答案:

答案 0 :(得分:1)

您应将id设置为主键(问题中未填写)。

相关问题