SQL – DELETE
Remove rows from a table permanently using the DELETE statement — and why the WHERE clause is critical.
Table of Contents
The DELETE statement permanently removes rows from a table. Like UPDATE, it is completely unforgiving without a WHERE clause — DELETE FROM students will wipe out the entire table in an instant, with no warning and no undo.
Always develop the habit of running your filter as a SELECT first, confirming the rows you intend to delete, and only then issuing the DELETE. In production systems, most engineers wrap deletes inside a transaction so they can roll back if something goes wrong.
TRUNCATE vs DELETE
| DELETE | TRUNCATE | |
|---|---|---|
| Can use WHERE | ✅ Yes | ❌ No |
| Is a transaction | ✅ Yes | ❌ No |
| Speed on large tables | Slower | Faster |
| Keeps table structure | ✅ Yes | ✅ Yes |
Try It Yourself — Interactive SQL Editor
Edit the query below and click Run Query ▶ to see live results powered by SQLite running directly in your browser.
Key Points
- ALWAYS use WHERE with DELETE — no WHERE = delete all rows
- Deleted rows are gone permanently (unless using transactions)
- Run SELECT with the same WHERE first to preview what will be deleted
- Use TRUNCATE when you want to empty an entire table quickly
Pro Tip from CodesCompiler: The best way to learn SQL is to break things intentionally — modify the query above, change the WHERE conditions, try different columns. Every error teaches you something the docs cannot.
In the next lesson, we continue exploring SQL’s powerful feature set to build your database mastery.