INSERT basics
- SQL course
- Beginner
- Lesson 71/115
- 4 min
Add a new row with INSERT INTO.
INSERT basics
With INSERT INTO you add a new row to a table. Columns and values go in parentheses.
INSERT INTO products (id, name, price)
VALUES (1, 'Kalem', 5);This query adds one row to the products table.
The values given with VALUES are inserted into products as new rows.
INSERT basics — details
After INSERT INTO comes the table name, columns in parentheses, then VALUES and the values. Text values go in single quotes.
Practice INSERT basics
Insert into products the row id=1, name='Pen', price=5.
Starter code
-- add a product
INSERT INTO products
VALUESSample solution
INSERT INTO products (id, name, price)
VALUES (1, 'Kalem', 5)Expected output
1 satır eklendi
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 What comes after INSERT INTO?
- A value
- The table name Correct answer
- The column name
- A condition
Explanation: The table name follows INSERT INTO.
2 Values
INSERT INTO products (id, name)
____ (1, 'Kalem');
INSERT INTO products (id, name)
VALUES (1, 'Kalem');
Explanation: After the column list, VALUES lists the values to insert.
3 INSERT basics: match the terms
| Term | Meaning |
|---|---|
INSERT |
insert |
INTO |
into |
VALUES |
values |
SELECT |
read |