⚡ 180+ new openings posted today

SQL DELETE Statement

What is the DELETE Statement in SQL ?

Answer: The SQL DELETE statement is used to delete existing records from a table. We can use the WHERE clause with a DELETE query to delete the selected rows, otherwise all the records would be deleted.

Syntax

DELETE FROM table_name
WHERE condition;

You can combine N number of conditions using the AND or the OR operator.

Example

Suppose we have an Employees table:

Employee_IDEmployee_NameSalary
101Anjali50000
102Priya45000
103Amit55000

If we want to delete Priya’s record:

DELETE FROM Employees
WHERE Employee_ID = 102;

After DELETE

Employee_IDEmployee_NameSalary
101Anjali50000
103Amit55000

DELETE Example without WHERE CLAUSE (Delete All Records)

Important: If you use DELETE without a WHERE clause, all records in the table will be deleted, but the table structure will remain.

To delete all records from a table, use the DELETE statement without a WHERE clause.

DELETE FROM Employees;

After DELETE

Employee_IDEmployee_NameSalary

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top