DELETE command in SQL

The DELETE statement in SQL is used to remove rows from a table. It's important to use the DELETE statement carefully, especially when not specifying a WHERE clause, as it can remove all rows from the table.

SQL Syntax

DELETE FROM table_name
WHERE condition;

The syntax has the following parameters:

Example: Delete Specific Rows Use the WHERE clause to specify which rows to delete. Suppose we have a table named employees and we want to delete an employee with a specific employee_id.

SQL

DELETE FROM employees
WHERE employee_id = 10;

This statement deletes the row from the employees table where the employee_id is 10.

Example: Delete All Rows To delete all rows from a table, we can omit the WHERE clause. Be cautious with this operation as it removes all data from the table.

SQL

DELETE FROM employees;

This statement deletes all rows from the employees table, but the table itself is not deleted.