Is there a way to do upserts in PostgreSQL
See original GitHub issueI’m relying on using INSERT ... ON CONFLICT (internal_id) DO NOTHING
or ``INSERT … ON CONFLICT (internal_id) DO UPDATE …` operations. Especially those updates are tedious to write for wider tables (each property name repeated like 5 times…). Is there a way this library could help me?
If the answer is no, but you’d like to have this functionality, I’d be happy to implement that.
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (5 by maintainers)
Top Results From Across the Web
UPSERT Operation in PostgreSQL
In PostgreSQL, the UPSERT operation means either UPDATE or INSERT operation. The UPSERT operation allows us to either insert a row or skip...
Read more >PostgreSQL Upsert Using INSERT ON CONFLICT statement
This tutorial shows you how to use the PostgreSQL upsert feature to insert or update data if the row that is being inserted...
Read more >PostgreSQL - Upsert
The UPSERT statement is a DBMS feature that allows a DML statement's author to either insert a row or if the row already...
Read more >UPSERT - PostgreSQL wiki
"UPSERT" is a DBMS feature that allows a DML statement's author to atomically either insert a row, or on the basis of the...
Read more >PostgreSQL — How to UPSERT safely, easily and fast
DELETE INTO another table · UPDATE INTO another table · Insert, delete and update in ONE statement · UPDATE SELECT a batch of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’d rather say that SQL server is an antipattern… His amazing solution is not that great, since it will only work properly in SERIALIZABLE mode which will lead to even more problems on this joke DBMS (otherwise you might get conflict. The whole point of doing upserts is to get rid of them).
If we have to support Microsoft SQL, I’m definitely not going to implement it. I’ll close this issue, as it does not seem as easy to solve given the constants. Probably best to rely on custom helper functions for a specific use case…
MERGE in sql server has issues …… https://sqlperformance.com/2020/09/locking/upsert-anti-pattern