The best SQL DELETE statement Tutorial In 2024, In this tutorial you can learn SQL DELETE statement,The demo database,SQL DELETE examples,Examples,Delete all data,
DELETE statement to delete records in the table is used.
DELETE statement to delete rows in a table.
Note that SQL DELETE statement WHERE clause! WHERE clause specifies which record or records which need to be removed. If you omit the WHERE clause, all records will be deleted! |
In this tutorial, we will use w3big sample database.
The following is a selected "Websites" table data:
+----+--------------+---------------------------+-------+---------+ | id | name | url | alexa | country | +----+--------------+---------------------------+-------+---------+ | 1 | Google | https://www.google.cm/ | 1 | USA | | 2 | 淘宝 | https://www.taobao.com/ | 13 | CN | | 3 | 本教程 | http://www.w3write.com/ | 4689 | CN | | 4 | 微博 | http://weibo.com/ | 20 | CN | | 5 | Facebook | https://www.facebook.com/ | 3 | USA | | 6 | 百度 | https://www.baidu.com/ | 4 | CN | | 7 | stackoverflow | http://stackoverflow.com/ | 0 | IND | +----+---------------+---------------------------+-------+---------+
Suppose we "Websites" list to remove from the site called "Baidu" and the country is CN's website.
We use the following SQL statement:
Execute the above SQL, then read the "Websites" list, the data is as follows:
You can delete the table without conditions, delete all the rows in the table. This means that the table structure, attributes, indexes will remain unchanged:
NOTE: When youdelete a record to be extra careful! Because you can not be repeated!