In INSERT INTO t VALUES (...) ON CONFLICT (id) DO UPDATE SET n = excluded.n, what does excluded refer to?
Correct answer
C. The row proposed for insertion, whose values feed the update expression
20 views
C. The row proposed for insertion, whose values feed the update expression
20 views
In PostgreSQL's upsert, excluded is the pseudo-table holding the row the INSERT tried to add, so SET n = excluded.n copies the incoming value over the stored one. The stored row can also be referenced by the target table's own name to compute arithmetic such as n = t.n + excluded.n. Without a conflict target, ON CONFLICT DO NOTHING applies to any unique violation.
Asked in: NTS, PPSC IT, Interviews
Not sure why the answer is C? Ask here and get an explanation.