DELETE statement
The SQL statement that removes rows from a table, choosing them with WHERE.
In more detail
Without WHERE it empties the table. Foreign keys may refuse the delete, or cascade it to child rows. For records with lasting value, prefer a soft delete, and log or archive destructive operations.
Related terms
- WHERE clause — The part of a query that keeps only the rows for which a condition is true.
- CASCADE — A foreign key action that deletes child rows automatically when their parent row is deleted.
- soft delete — Marking a row as deleted, for example by setting a deleted_at date, instead of removing it.
- affected row count — The number of rows an INSERT, UPDATE or DELETE actually changed, reported back to the program that ran it.
Taught in
- Privacy Principles, GDPR Subject Rights & Minimization — Cybersecurity Fundamentals, GRC & Cryptography
- Keys, Constraints And Referential Integrity — PostgreSQL, Indexing & Relational Data Modeling
- Updating And Deleting Safely — PostgreSQL, Indexing & Relational Data Modeling