Skip to content
Related Articles
Get the best out of our app
GFG App
Open App
geeksforgeeks
Browser
Continue

Related Articles

SQL | DELETE Statement

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

Pre-requisites: SQL Commands

Existing records in a table can be deleted using the SQL DELETE Statement. We can delete a single record or multiple records depending on the condition we specify in the WHERE clause.

Syntax: 

DELETE FROM table_name WHERE some_condition;

table_name: name of the table

Parameter Explanation

  • Some_condition: condition to choose a particular record.
  • DELETE FROM table_name(means we have to delete from table.

Note: We can delete single as well as multiple records depending on the condition we provide in the WHERE clause. If we omit the WHERE clause then all of the records will be deleted and the table will be empty. 

The sample table is as follows: 

 

Deleting Single Record

Delete the rows where NAME = ‘Rithvik’. This will delete only the fourth row.

Query:

DELETE FROM GFG_EMPLOyees WHERE NAME = 'Rithvik';  

Output:

 

 Deleting Multiple Records

 Delete the rows from the table  GFG_EMPLOyees where the department is “Development”. This will delete 2 rows(the first row and the seventh row).

Query:

DELETE FROM GFG_EMPLOyees 
WHERE department = 'Development';

Output:

 

Delete All of the Records

There are two queries to do this as shown below,

Query:

DELETE FROM GFG_EMPLOyees;

Or

DELETE * FROM GFG_EMPLOyees; 

Output:

All of the records in the table will be deleted, there are no records left to display. The table GFG_EMPLOyees  will become empty!

 

Important Note: DELETE is a DML (Data Manipulation Language) command hence operation performed by DELETE can be rolled back or undone.

SQL Quiz This article is contributed by Harsh Agarwal. If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to review-team@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks. 

Please write comments if you find anything incorrect, or if you want to share more information about the topic discussed above.

My Personal Notes arrow_drop_up
Last Updated : 31 Mar, 2023
Like Article
Save Article
Similar Reads