SQL DELETE Statement
Syntax
The DELETE statement in SQL is used to remove rows from a table. Use the WHERE clause to specify which rows to delete; omitting it deletes all rows.
-- Delete specific rowsDELETE FROM table_nameWHERE condition;
-- Delete all rows (use cautiously)DELETE FROM table_name;Example
-- Delete specific rowsDELETE FROM employeesWHERE name = 'John Doe';/* Deletes the row:| id | name | department | age ||----|------------|------------|-----|| 1 | John Doe | Sales | 35 |*/
-- Delete rows based on a conditionDELETE FROM employeesWHERE age > 30;/* Deletes:| id | name | department | age ||----|-------------|------------|-----|| 3 | Alice Brown | General | 40 |*/
-- Delete all rows from the tableDELETE FROM employees;/* Deletes all rows, leaving the table structure intact:| id | name | department | age ||----|------------|------------|-----|| (no rows) | | |*/