INSERT

Adds new rows to a table. Supports inserting multiple rows and the RETURNING clause to get inserted values.

Syntax

postgresql
INSERT INTO table (cols) VALUES (vals) RETURNING cols;

Example

postgresql
INSERT INTO users (name, email)
VALUES ('Alice', 'alice@example.com')
RETURNING id, created_at;

-- Insert multiple:
INSERT INTO tags (name) VALUES ('tech'), ('news'), ('sports');