The DELETE
statement removes rows from a table.
DELETE FROM table_name
WHERE condition;
table_name
: The table you want to delete rows from.WHERE
: Specifies which rows to delete.Warning: If omitted, all rows are deleted!DELETE FROM cats
WHERE cat_id = 2;
Explanation:
Removes the row where cat_id
is 2
from the cats
table.
DELETE FROM cats
WHERE age > 10;
Explanation:
Deletes all cats older than 10 years.
DELETE FROM cats;
Explanation:
Removes all rows from the cats
table.
The table structure remains.