Inserting data
- SQL course
- Beginner
- Lesson 21/115
- 5 min
Write the query to add a new record with INSERT.
Inserting data
With INSERT we add a new record to the table. Columns and values go in parentheses, separated by commas.
INSERT INTO notes (id, title, body)
VALUES (3, 'Market', 'Süt, ekmek');This adds one row to the notes table.
The values given with VALUES are inserted into notes as new rows.
Inserting data — details
Create is the C in CRUD. After INSERT INTO comes the table name, columns in parentheses, then VALUES and the values. Text values go in single quotes.
Practice Inserting data
Insert into notes the row id=3, title='Market', body='Milk, bread'.
Starter code
-- add a new note
INSERT INTO notes (id, title, body)
VALUESSample solution
INSERT INTO notes (id, title, body)
VALUES (3, 'Market', 'Süt, ekmek')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 Insert value
INSERT INTO notes (id, title)
____ (4, 'Görev');
INSERT INTO notes (id, title)
VALUES (4, 'Görev');
Explanation: In INSERT INTO, VALUES gives the values to insert after the column list.
2 What comes after INSERT INTO?
- The table name Correct answer
- A value
- The column name
- A condition
Explanation: The table name follows INSERT INTO.
3 Inserting data: match the terms
| Term | Meaning |
|---|---|
INSERT |
insert |
INTO |
into |
VALUES |
values |
SELECT |
read |