PostgreSQL Enterprise (50 Qs)•Part 1: Basic & Foundational Concepts (Junior / Entry-Level)
What is the `RETURNING` clause in PostgreSQL?
junior LevelCode ExampleDatabases & SQLPostgreSQL
In Simple Words:
Allows INSERT, UPDATE, and DELETE queries to return modified or inserted column values directly without executing a subsequent SELECT query:
sql
-- Insert a new user and retrieve the generated serial ID and creation date:
INSERT INTO users (username, email)
VALUES ('alexm', 'alex@example.com')
RETURNING id, created_at;