DELETE removes entire rows from a table. It shares the exact same danger as UPDATE: run it without a WHERE clause and every row in the table is gone, not just the ones you meant to remove.
Learning Objectives
- Write a DELETE statement that removes specific rows.
- Understand the consequences of running DELETE without WHERE.
WHERE Matches
Rows identified
DELETE FROM
Matched rows removed
Gone
Permanently, unless in a transaction
Basic DELETE
DELETE FROM names the table, WHERE narrows it down to specific rows, exactly the same condition syntax as SELECT and UPDATE. Every row matching the condition is removed entirely, not just cleared.
DELETE FROM employees WHERE department = 'Research' AND salary < 85000;
DELETE Without WHERE
Valid SQL, no confirmation, and it empties the entire table. Exactly the same risk as UPDATE without WHERE, and exactly the same discipline applies: preview with a matching SELECT first if there's any doubt.
DELETE FROM employees;
Try It Yourself
Write a DELETE that removes employees earning under 50000 in the Research department.
DELETE FROM employees WHERE department = 'Research' AND salary < 50000;
Frequently Asked Questions
Does deleting a row reduce the next auto-increment value?
No. Deleting a row doesn't reset or reuse its ID, the next inserted row still gets the next number in sequence.
Can I undo a DELETE?
Only if it was run inside a transaction that hasn't been committed yet, covered later in this course, or by restoring from a backup. Once committed, it's permanent.
Common Beginner Mistakes
Running DELETE without a WHERE clause
Exactly like UPDATE, this is valid SQL that silently empties the entire table with no confirmation.
Assuming a DELETE blocked by a foreign key reference is a bug
It's usually the database protecting you from leaving other tables' rows pointing at data that no longer exists, covered in the Foreign Key lesson later in this course.
Best Practices
- Preview a DELETE's WHERE clause as a SELECT first, confirm the row count matches what you expect, before running the actual delete.
- Wrap any DELETE you're uncertain about in a transaction so it can be rolled back if the result looks wrong.
Interview Questions
Write a DELETE that removes employees who left the company (status = 'inactive') and earned under 50000.
DELETE FROM employees WHERE status = 'inactive' AND salary < 50000; —straightforward AND condition, same pattern as a SELECT's WHERE clause.
What's the practical difference between DELETE FROM employees and DROP TABLE employees?
DELETE removes rows but keeps the table, its columns, and its constraints intact, empty but still there. DROP TABLE, covered later in this course, removes the table itself entirely, structure and all.
Summary
This lesson covered removing specific rows with DELETE FROM ... WHERE, and why running it without a WHERE clause is one of the most dangerous mistakes in SQL.
What's Next?
The next lesson covers limiting how many rows a query returns, with LIMIT, TOP, and FETCH FIRST.
Ready to Practice SQL?
Write and run real SQL queries online, right in your browser, no install or signup required. Pick a playground based on which database you want to practice on.
Both open a third-party SQL playground in a new tab. External site terms and privacy policy apply.