SQL DELETE


The SQL DELETE Query is used to delete the existing records from a table.

You can use WHERE clause with DELETE query to delete selected rows, otherwise all the records would be deleted.


SQL DELETE Syntax

Let's see the Syntax for the SQL DELETE statement:

DELETE FROM table_name [WHERE condition];

Here table_name is the table which has to be deleted. The WHERE clause in SQL DELETE statement is optional here. Here table_name is the table which has to be deleted. The WHERE clause in SQL DELETE statement is optional here.

SQL DELETE Example


Let us take a table, named ?EMPLOYEE? table.


ID EMP_NAME CITY SALARY
101 Adarsh Singh Obra 20,000
102 Sanjay Singh Meerut 18000
103 Priyanka Sharma Raipur 25000
104 Esha Singhal Delhi 26000

Example of delete with WHERE clause is given below:

DELETE FROM EMPLOYEE WHERE ID=101;

Resulting table after the query:

ID EMP_NAME CITY SALARY
102 Sanjay Singh Meerut 18000
103 Priyanka Sharma Raipur 25000
104 Esha Singhal Delhi 26000

Another example of delete statement is given below

DELETE FROM EMPLOYEE;

Resulting table after the query:

ID EMP_NAME CITY SALARY

It will delete all the records of EMPLOYEE table.

It will delete the all the records of EMPLOYEE table where ID is 101.

The WHERE clause in the SQL DELETE statement is optional and it identifies the rows in the column that gets deleted.

WHERE clause is used to prevent the deletion of all the rows in the table, If you don't use the WHERE clause you might loss all the rows.

Invalid DELETE Statement for ORACLE database


You cannot use * (asterisk) symbol to delete all the records.,/ DELETE * FROM EMPLOYEE;


Topics of SQL DELETE Statement


  • SQL DELETE TABLE
  • SQL DELETE ROW
  • SQL DELETE All Rows
  • SQL DELETE Duplicate Rows
  • SQL DELETE Database
  • SQL DELETE VIEW
  • SQL DELETE JOIN