Answer the question
In order to leave comments, you need to log in
How to overwrite rows in PostgreSql?
Good afternoon,
there is a query executed via JDBC - INSERT INTO TableName( id, name) VALUES ('1', 'new_name');
An entry with this key already exists, and duplicate key value violates unique constraint "TableName_pkey" occurs,
how to completely overwrite the entire entry if an entry with this key already exists?
ON CONFLICT DO UPDATE - wants to specify which fields need to be updated.
You need to do a complete overwrite.
Answer the question
In order to leave comments, you need to log in
Postgre has no such mechanism.
If you often have such a situation, then it is better to start with update, because upsert is a rather expensive thing.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question