O
O
office12018-10-09 11:53:51
PostgreSQL
office1, 2018-10-09 11:53:51

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

2 answer(s)
V
Vyacheslav Uspensky, 2018-10-12
@Kwisatz

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 question

Ask a Question

731 491 924 answers to any question