SQL DELETE FROM Statement


The DELETE statement is used to delete existing records in a table. Notice the where clause in the delete syntax. The where clause specifies which records that should be deleted. If you omit the where clause, all records will be deleted!

Assume the person table is given below:
DELETE FROM  table-name [ WHERE  condition ];

SQL> DELETE FROM  student  WHERE  student_id = '2';

person_id last_name first_name address city
1 Hansen Ola Timoteivn 10 Sandnes
2 Svendson Tove Borgvn 23 Sandnes
3 Pettersen Kari Storgt 20 Stavanger
4 Rasmussen Nina Stien 12 Stavanger

 DELETE FROM  person  WHERE  last_name = 'Rasmussen';
 DELETE FROM  person;
person_id last_name first_name address city
1 Hansen Ola Timoteivn 10 Sandnes
2 Svendson Tove Borgvn 23 Sandnes
3 Pettersen Kari Storgt 20 Stavanger
person_id last_name first_name address city



Demonstration
Below is an SQL test area from W3Schools, which uses the well-known Northwind sample database. The tables here are for read only because of the problem of embedding the scripts. For a fully working example, check this by using Chrome.

SQL Statement:

Edit the SQL statement and click     to see the result, or  

Result:
The Database includes:
The Database includes:

TablenameRecord
Customers91
Categories8
Employees10
OrderDetails518
Orders196
Products77
Shippers3
Suppliers29