RETURNING can give you the old row too
Since Postgres 18, RETURNING can name both the previous and the new values in one statement. No trigger, no second query to see what changed.
UPDATE accounts SET balance = balance - 50 WHERE id = 7
RETURNING old.balance AS before, new.balance AS after;Handy for audit rows and for the "what did I just overwrite" moment during a migration.
postgresql