📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials PostgreSQL Essentials INSERT INTO

INSERT INTO

5 min read
INSERT INTO adds rows to a table. Use the RETURNING clause to get the generated ID back. Insert multiple rows in one statement for better performance. Always use parameterised queries to prevent SQL injection.

Inserting Data

-- Single row
INSERT INTO users (name, email, age)
VALUES ('Alice', 'alice@example.com', 28);

-- Multiple rows
INSERT INTO users (name, email, age) VALUES
  ('Bob',   'bob@example.com',   32),
  ('Carol', 'carol@example.com', 24);

-- Returning inserted row
INSERT INTO users (name, email)
VALUES ('Dave', 'dave@example.com')
RETURNING id, created;