DELETE
deleting matching rows
Overview
DELETE removes rows that satisfy WHERE; without WHERE it removes every row while keeping the table structure. Before execution, run SELECT with the same predicate, check related tables, foreign-key behavior, and expected row count, then use a reversible transaction. Large deletes can create long transactions and locks, so consider batching and archival needs.
Basic syntax
DELETE FROM orders WHERE id = 1;
Examples
DELETE example
Delete order id 1 with an explicit primary-key predicate so no other sample rows are affected.
Sample table
orders| id |
|---|
| 1 |
| 2 |
| 3 |
| 4 |
Run result
| id |
|---|
| 2 |
| 3 |
| 4 |
Common issues
Checking the same WHERE predicate reveals an overly broad or missing condition before rows are changed.
UPDATE changes every row and DELETE removes every row, so verify scope before production use.
Use a transaction, inspect affected rows, commit only after verification, and keep recoverable backups for critical data.
Tags
Was this explanation clear?
Thanks. This feedback will inform the next content review.