UPDATE t SET v = s.v FROM src s WHERE t.id = s.id carries which hazard when several src rows share one id?
Correct answer
C. If several source rows match a target row, one arbitrary value wins out
18 views
C. If several source rows match a target row, one arbitrary value wins out
18 views
UPDATE ... FROM joins the target to a source table, and PostgreSQL does not define which source row is used when several match the same target row: the result is non-deterministic rather than an error. The usual cure is a subquery that aggregates to exactly one row per key before joining. MySQL's multi-table UPDATE and SQL Server's UPDATE with a join behave the same way.
Asked in: NTS, PPSC IT, Interviews
Not sure why the answer is C? Ask here and get an explanation.