INSERT — Adding Rows in SQL
Put new records into a table
INSERT adds new rows to a table. You name the target table, optionally the columns you are supplying, and VALUES for one or many rows. Columns you skip receive their DEFAULT (or NULL). Modern SQL inserts multiple rows in a single statement, which is far faster than looping.
Name table and columns
INSERT INTO employees (id, name, department, salary, age) — always list columns explicitly; it survives schema changes and reads clearly.
Supply matching VALUES
One tuple per row, same order as your column list. Mismatched count or a type violation aborts the whole statement.
Insert many rows at once
Separate tuples with commas — one statement, many rows. Massively faster than looping single INSERTs.
Let defaults fill gaps
Any column you omit receives its DEFAULT, or NULL if none was declared — that is how bonus stays empty for most employees.
Respect the constraints
Duplicate primary keys or NOT NULL violations fail the entire multi-row insert — the table never ends up half-changed.
| id | name | department | salary | age |
|---|
1INSERT INTO employees (id, name, department, salary, age)2VALUES3 (7, 'Grace', 'Engineering', 81000, 31),4 (8, 'Hassan', 'Sales', 49500, 24);
| id | name | department | salary | age |
|---|---|---|---|---|
| 7 | Grace | Engineering | 81000 | 31 |
| 8 | Hassan | Sales | 49500 | 24 |
Two complete rows arrive in one statement. Omitting a column (say age) would store NULL there unless a DEFAULT was declared.
Single row
The plainest insert — full column list, one tuple.
1INSERT INTO employees (id, name, department, salary, age)2VALUES (7, 'Grace', 'Engineering', 81000, 31);
| id | name | department | salary | age |
|---|---|---|---|---|
| 7 | Grace | Engineering | 81000 | 31 |
Multi-row insert
Many tuples, one statement — one round trip, one transaction.
1INSERT INTO employees (id, name, department, salary, age)2VALUES3 (8, 'Hassan', 'Sales', 49500, 24),4 (9, 'Iris', 'Marketing', 61000, 27);
| id | name | department | salary | age |
|---|---|---|---|---|
| 8 | Hassan | Sales | 49500 | 24 |
| 9 | Iris | Marketing | 61000 | 27 |
Partial insert
Omitted columns fall back to DEFAULT or NULL.
1INSERT INTO employees (id, name, department, salary)2VALUES (10, 'Jun', 'Sales', 47000);
| id | name | department | salary | age |
|---|---|---|---|---|
| 10 | Jun | Sales | 47000 | NULL |
Constraint failure
A duplicate key fails the whole statement.
1INSERT INTO employees (id, name, department, salary, age)2VALUES (7, 'Impostor', 'Sales', 100, 99);3-- ERROR: duplicate key id = 7
Recommended resourcesAffiliate links · may earn us a commission
Recommended for learners
Practice what you learned
Take the queries you just visualized and see the data structures that power real databases.