SQL Delete
DELETE removes rows, while leaving the table itself in place. Before deleting anything important, decide whether you need an audit record, a soft-delete flag, or a retention policy instead.
Understand the idea
The example first adds a disposable customer who has no orders, then deletes that exact identifier. Foreign keys can prevent deletion of a customer who still has related orders. That protection is useful: it forces you to decide what should happen to the related records rather than accidentally leaving broken references.
Where to try it
Run this example in the SQL playground. The lesson link loads the shop tables and sample rows before this query. Select Run when you are ready. Every run starts fresh, so your changes do not affect the website or a previous run.
SQLite sample data · MySQL / MariaDB sample data · See the sample tables
A worked example
INSERT INTO customers (customer_id, name) VALUES (5, 'Temporary');
DELETE FROM customers WHERE customer_id = 5;
SELECT COUNT(*) AS remaining FROM customers WHERE customer_id = 5;
Read the result
The final count is 0. The temporary row is gone, but the four original customers remain. The table structure still exists and can accept more rows.
Try one change
Change the final SELECT to COUNT(*) over the entire customers table and confirm that the original count is still four.