medium10 pts · first answer countsindexingsql
ON CONFLICT needs a unique index
INSERT INTO stock (sku, qty) VALUES ($1, $2) ON CONFLICT (sku) DO UPDATE SET qty = stock.qty + EXCLUDED.qty fails with "there is no unique or exclusion constraint matching the ON CONFLICT specification". What is missing?
Discussion 0
Join free to post in the discussion.
Related questions
- Purpose of a primary keyDatabase Administrator
- When a B-tree index helpsDatabase Administrator
- INNER JOIN vs LEFT JOINDatabase Administrator
- DELETE vs TRUNCATEDatabase Administrator
- Filtering rows where a value is NULLDatabase Administrator
- COUNT(*) vs COUNT(column)Database Administrator
- What a foreign key enforcesDatabase Administrator
- WHERE vs HAVINGDatabase Administrator