What Is DELETE in SQL?
The DELETE statement in SQL is used to remove one or more rows from a table. It is part of the Data Manipulation Language (DML) and permanently deletes data (unless you're using transactions and rollbacks).
Basic Syntax
DELETE FROM table_name
WHERE condition;
Important: Without WHERE, All Rows Are Deleted!
DELETE FROM employees; -- deletes ALL rows in the table!
Example: Delete a Specific Row
Table: employees
| id |
name |
department |
| 1 |
Alice |
HR |
| 2 |
Bob |
IT |
| 3 |
Carol |
HR |
DELETE FROM employees
WHERE id = 2;
Delete Based on a Condition
DELETE FROM employees
WHERE department = 'HR';
Delete Using a Subquery
DELETE FROM employees
WHERE id IN (
SELECT employee_id FROM resignations
);
DELETE vs TRUNCATE vs DROP
| Command |
What It Does |
Can Use WHERE |
Removes Table Structure? |
| DELETE |
Removes selected rows |
✅ Yes |
❌ No |
| TRUNCATE |
Removes all rows (faster) |
❌ No |
❌ No |
| DROP |
Deletes the entire table |
❌ No |
✅ Yes |