Deleting rows
Handout
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version.
Removing rows with DELETE
DELETE removes the rows that match a WHERE condition:
DELETE FROM product WHERE code = 'P03';
Only the matching rows are removed; the table and its other rows stay.
The same warning
Like UPDATE, a DELETE with no WHERE hits every row:
DELETE FROM product; -- empties the whole table!
Always check your WHERE before running a DELETE. The checker runs your DELETE, then reads the table back to confirm the right row is gone.
Delete the product with code 'P03' from the product table. (Afterwards only P01 and P02 remain.)
Click Run to see the output here.