postrges on conflict update with all columns as unique constraint
1
vote
1
answer
1234
views
I have a table with columns 'id', 'a', 'b, 'c', 'd'.
Also, I have a unique constraint on ('a', 'b', 'c', 'd') so no entries can be added where all those fields are the same.
I want to upsert entries e.g. I have in db:
1 a_value b_value c_value d_value
and I'm upserting
INSERT INTO MYTABLE(a, b, c, d) values ('a_value', 'b_value', 'c_value', 'd_value__new') on conflict (a, b, c, d) DO UPDATE SET d= excluded.d;
But this creates new entry when I expected that it will update d_value to d_value_new on existing entry.
What am I doing wrong?
See example here:
https://dbfiddle.uk/nL7fRpt_
Asked by kichma
(13 rep)
Jan 16, 2024, 02:09 PM
Last activity: Jan 21, 2024, 05:08 PM
Last activity: Jan 21, 2024, 05:08 PM