DELETE basics
- SQL course
- Beginner
- Lesson 83/115
- 4 min
Delete rows with DELETE.
DELETE basics
With DELETE FROM you remove rows from a table. WHERE picks which rows to delete.
DELETE FROM products
WHERE id = 1;This query removes product 1.
Rows are deleted from products. Only the rows where id = 1 holds are affected.
DELETE basics — details
Without WHERE, DELETE removes every row; always give a condition. Deleted data cannot be undone.
Practice DELETE basics
Delete the row with id=1 from products.
Starter code
-- delete row
DELETE FROM products
WHERESample solution
DELETE FROM products
WHERE id = 1Expected output
1 satır silindi
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 What happens if WHERE is missing in DELETE?
- Only the first row
- All rows are deleted Correct answer
- Raises an error
- No rows
Explanation: DELETE without WHERE deletes every row.
2 Delete row
DELETE ____ products
WHERE id = 1;
DELETE FROM products
WHERE id = 1;
Explanation: DELETE FROM table WHERE condition deletes only the rows that match.
3 DELETE basics: match the terms
| Term | Meaning |
|---|---|
DELETE |
delete |
FROM |
table |
WHERE |
condition |
UPDATE |
update |