N
N
NubasLol2022-02-10 19:24:17
PostgreSQL
NubasLol, 2022-02-10 19:24:17

Is it possible to get around the "duplicate key value violates unique constraint" error when updating?

Is it possible to bypass the unique key constraint if I update the same row with new data?

for example table cards [id, user_id, status]

user_id is a unique value.

we have record

180, 1, "bla-bla"

Do

UPDATE cards SET user_id  = 1, status = 'test', WHERE id = 180


We get an error. How to avoid it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
rPman, 2022-02-10
@NubasLol

duplicate key value violates unique constraint
google translate:
duplicate key value violates unique constraint
doesn't look like anything?
one of the indexes of type unique in the table does not allow, the value after the update will be repeated

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question