Skip to content
masterclass Buddy

PostgreSQL · Command

RETURNING

RETURNING lets INSERT, UPDATE, DELETE, and MERGE return data from rows they change. It can avoid a second query and can expose generated, old, new, or trigger-modified values.

Last updated

Syntax

[ RETURNING [ WITH ( { OLD | NEW } AS output_alias [, ...] ) ] { * | output_expression [ [ AS ] output_name ] } [, ...] ]

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • INSERT
  • UPDATE
  • DELETE
  • MERGE
  • OLD
  • NEW
  • RETURN NEXT
  • RETURN QUERY

Source: PostgreSQL: Documentation: 18: 6.4. Returning Data from Modified Rows. Checked 2026-11-03.