Lesson 19
Intermediate Level
19 of 30 lessons
DELETE Statement
Learn how to remove data from tables using DELETE statements with WHERE clause. The DELETE statement is essential for data management.
Introduction
The DELETE statement removes existing rows from a table based on a condition.
Basic Syntax
DELETE FROM table_name
WHERE condition;
Example: Delete Employee by ID
DELETE FROM employees
WHERE employee_id = 101;
Delete Multiple Rows
DELETE FROM employees
WHERE department_id = 10;
Delete All Rows
Warning: Omitting the WHERE clause deletes all rows from the table.
DELETE FROM employees;
Best Practices
- Always use
WHEREclause to avoid accidental deletion of all data. - Test your
WHEREcondition with aSELECTfirst. - Use transactions (
COMMITandROLLBACK) for safety.
Practice Task
- Delete employee with
employee_id105. - Remove all employees from a specific department.
- Try deleting all rows from a test table (use with caution).