SQL DELETE
In this tutorial, you will learn about the SQL DELETE concept by using examples.
In Structured Query Language (SQL), we fetch the data from the database table using SELECT Statement and modify the data using the UPDATE Database. What if we want to remove or delete the data from the table?
If you need to remove or delete the row or table from the database, you have to use the DELETE Statement. Also, you can delete or remove one row or multiple rows from the table using a condition.
The syntax for the SQL DELETE query is as follows:
DELETE FROM TABLE_NAME;
The above syntax will delete all the records or data from the table specified in the delete query.
What if we want to delete a single row from a table? Then in such a case, we will use the Where Clause, which is optional in the delete statement, where the clause is used to identify the deleted row.
Syntax:
DELETE FROM TABLENAME WHERE [CONDITIONS];
Let's understand the concept of the SQL DELETE command with the help of an example.
Consider the already existing table with the following data:
Table Name: Employee_Details
E_Id | E_Name | E_Salary | E_City | Designation | Age |
1001 | Kirti Kirtane | 60000 | Mumbai | Project Manager | 26 |
1002 | Akash Vani | 40000 | Pune | System Engineer | 22 |
1003 | Anupam Mishra | 55000 | Hyderabad | Project Manager | 25 |
1004 | Anuj Rawat | 45000 | Hyderabad | Software Tester | 25 |
1005 | Akanksha Yadav | 42000 | Pune | Associate Software Developer | 23 |
1006 | Bhavesh Wani | 50000 | Mumbai | Associate Software Developer | 24 |
2001 | Sakshi Sharma | 40000 | Bangalore | System Engineer | 23 |
2002 | Megha Ghatole | 45000 | Bangalore | Software Tester | 24 |
2003 | Surbhi Nahar | 60000 | Pune | Project Manager | 26 |
2004 | Supriya Shende | 55000 | Mumbai | Software Developer | 25 |
2005 | Prachi Sharma | 52000 | Hyderabad | Software Developer | 24 |
2006 | Purva Dhandekar | 50000 | Bangalore | Software Tester | 23 |
3001 | Shruti Deshpande | 60000 | Pune | Project Manager | 26 |
3002 | Rohit Nikam | 40000 | Hyderabad | System Engineer | 23 |
3003 | Sahil Jain | 50000 | Mumbai | Software Developer | 24 |
Example1: You want to delete the data by employee id from table employee_details. We will execute the below query using the where clause as follows:
DELETE FROM Employee_Details WHERE E_Id = 3003;
The above statement will delete the employee's data whose id number is 3003 from the employee's table.
To check whether the above query is successfully executed or not, we will execute the SELECT statement.
The output of the above query is as follows:
SELECT * FROM Employee_Details;
E_Id | E_Name | E_Salary | E_City | Designation | Age |
1001 | Kirti Kirtane | 60000 | Mumbai | Project Manager | 26 |
1002 | Akash Vani | 40000 | Pune | System Engineer | 22 |
1003 | Anupam Mishra | 55000 | Hyderabad | Project Manager | 25 |
1004 | Anuj Rawat | 45000 | Hyderabad | Software Tester | 25 |
1005 | Akanksha Yadav | 42000 | Pune | Associate Software Developer | 23 |
1006 | Bhavesh Wani | 50000 | Mumbai | Associate Software Developer | 24 |
2001 | Sakshi Sharma | 40000 | Bangalore | System Engineer | 23 |
2002 | Megha Ghatole | 45000 | Bangalore | Software Tester | 24 |
2003 | Surbhi Nahar | 60000 | Pune | Project Manager | 26 |
2004 | Supriya Shende | 55000 | Mumbai | Software Developer | 25 |
2005 | Prachi Sharma | 52000 | Hyderabad | Software Developer | 24 |
2006 | Purva Dhandekar | 50000 | Bangalore | Software Tester | 23 |
3001 | Shruti Deshpande | 60000 | Pune | Project Manager | 26 |
3002 | Rohit Nikam | 40000 | Hyderabad | System Engineer | 23 |

There is no such data for employee id 3003 in the table because we removed the data from the table.
The above query deletes one row from the table. What if you want to delete multiple rows at a time from the table? Then try the below example or statement.
Example2: Now, if you want to delete data of those employees who belong to the city name 'Hyderabad', then we will execute the below delete statement:
DELETE FROM Employee_Details WHERE E_City = ‘Hyderabad’;
The Above query will delete all the data of employees from the employee_details table who belong to the city name Hyderabad.
To check whether the above query is successfully executed or not, we will execute the SELECT statement.
The output of the above query is as follows:
SELECT * FROM Employee_Details;
E_Id | E_Name | E_Salary | E_City | Designation | Age |
1001 | Kirti Kirtane | 60000 | Mumbai | Project Manager | 26 |
1002 | Akash Vani | 40000 | Pune | System Engineer | 22 |
1005 | Akanksha Yadav | 42000 | Pune | Associate Software Developer | 23 |
1006 | Bhavesh Wani | 50000 | Mumbai | Associate Software Developer | 24 |
2001 | Sakshi Sharma | 40000 | Bangalore | System Engineer | 23 |
2002 | Megha Ghatole | 45000 | Bangalore | Software Tester | 24 |
2003 | Surbhi Nahar | 60000 | Pune | Project Manager | 26 |
2004 | Supriya Shende | 55000 | Mumbai | Software Developer | 25 |
2006 | Purva Dhandekar | 50000 | Bangalore | Software Tester | 23 |
3001 | Shruti Deshpande | 60000 | Pune | Project Manager | 26 |

Employee ID numbers 1003, 1004, 2005, and 3002 are deleted from the table because that employee id belongs to the city Hyderabad which we deleted.
We learn single row deletion from the table and multiple row deletion. What if you want to delete or remove all the records from the table? For such a scenario, try the below example query or statement.
Example3: Suppose you want to delete all the records from the employee_details table. Use the below query as follows:
DELETE FROM Employee_Details;
The above query will delete all the data from the table.
To check whether the above query is successfully executed or not, we will execute the SELECT statement.
The output of the above query is as follows:
SELECT * FROM Employee_Details;
Output
