RETURNING

RETURNING makes INSERT, UPDATE or DELETE return the modified rows, with the desired columns, in a single query. It avoids an extra read to retrieve a generated identifier or the final values, and combines well with CTEs.

Example

INSERT INTO clients (nom) VALUES ('Léa') RETURNING id;

Related concepts

The whole glossary