HOME C C++ PYTHON JAVA HTML CSS JAVASCRIPT BOOTSTRAP JQUERY REACT PHP SQL AJAX JSON DATA SCIENCE AI

The SQL DELETE Statement

The DELETE statement is used to delete existing records in a table.

Syntax

 DELETE   FROM  table_names
 WHERE  condition;

Note: Be careful when updating records in a table! Notice the WHERE clause in the DELETE statement. The WHERE clause specifies which record(s) should be deleted. If you omit the WHERE clause, all records in the table will be deleted!

Demo Employee table


This employee table is used for examples:

demo employee table for null value

SQL DELETE Example


The following SQL statement deletes the employee "Rajeev Ranjan" from the "employee" table:

Example

 DELETE   FROM  employee 
 WHERE Employee_name =  'Rajeev Ranjan' ;
You can click on above box to edit the code and run again.

Output

delete row

Delete All Records


It is possible to delete all rows in a table without deleting the table. This means that the table structure, attributes, and indexes will be intact:

Syntax

 DELETE   FROM  table_name;

Delete a Table


To delete the table completely, use the DROP TABLE statement:

Syntax

 DROP   TABLE  table_name;