Multiple rows
- SQL course
- Beginner
- Lesson 73/115
- 4 min
Insert many rows in a single INSERT.
Multi-row insert
A single INSERT can add many rows. You separate value sets with commas.
INSERT INTO products (id, name, price)
VALUES (4, 'Çanta', 25), (5, 'Cetvel', 3);This query adds two rows in one query.
The values given with VALUES are inserted into products as new rows.
Multi-row insert — details
Multi-row insert is faster than one-by-one. Each value set goes in parentheses, separated by commas; no comma after the last set.
Practice Multi-row insert
Insert id=4 'Bag' and id=5 'Ruler' into products in one query.
Starter code
-- insert two rows
INSERT INTO products (id, name)
VALUESSample solution
INSERT INTO products (id, name)
VALUES (4, 'Çanta'), (5, 'Cetvel')Expected output
2 satır eklendi
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 Multiple rows: match the terms
| Term | Meaning |
|---|---|
INSERT |
insert |
VALUES |
values |
comma |
separate sets |
INTO |
into |
2 Two rows
INSERT INTO products (id, name) VALUES (1, 'A'), ____;
INSERT INTO products (id, name) VALUES (1, 'A'), (2, 'B');
Explanation: (2, 'B') is the right answer.
3 What separates value sets in multi-row insert?
- A space
- A colon
- A semicolon
- A comma Correct answer
Explanation: Value sets are separated by commas.