Part 41: Inserting Single Rows with INSERT INTO ... VALUES
The INSERT statement adds new records to a table.
1. Syntax
INSERT INTO users (email, password_hash, first_name, last_name)
VALUES ('alex@devify.com', 'hashed_pw_123', 'Alex', 'Vance');
2. Returning Inserted Data (RETURNING in PostgreSQL)
In PostgreSQL, retrieve auto-generated IDs immediately without a separate query:
INSERT INTO users (email, password_hash, first_name, last_name)
VALUES ('clara@devify.com', 'hashed_pw_456', 'Clara', 'Oswald')
RETURNING id, created_at;
Key Takeaways
- Always explicitly specify target column lists in
INSERT INTO. - Use
RETURNINGin PostgreSQL to retrieve generated IDs instantly.
In Part 42, we explore Bulk Inserting Multiple Rows Efficiently!

