On this page
  1. RETURNING
  2. Syntax & Overview
  3. Notes & Best Practices
  4. Example

RETURNING

Prev: `DELETE` | Up: clauses | Next: `ON CONFLICT`
Rel: clauses, SQL Query Execution Lifecycle
Ref: PostgreSQL — SQL Commands
Tags: #public #databases #sql #clauses #tier/core


Syntax & Overview

INSERT INTO items (name) VALUES ('widget') RETURNING id, created_at;

Returns generated IDs or updated columns atomically in the same round-trip.

Notes & Best Practices

Example

UPDATE tasks
SET status = 'done'
WHERE id = 42
RETURNING id, status, updated_at;

Linked from

Related notes