Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the function of the database delete statement delete

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you what the role of database deletion statement delete is, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

The database delete statement delete is used to delete one or more rows of data from a table in the syntax format "DELETE FROM [WHERE clause] [ORDER BY clause] [LIMIT clause]"; when you do not use the WHERE clause to qualify the deletion operation, all data will be deleted.

Delete statement delete

The DELETE statement can delete one or more rows of data from a table.

The syntax format is:

DELETE FROM [WHERE clause] [ORDER BY clause] [LIMIT clause]

The syntax is as follows:

Specifies the name of the table to delete the data

ORDER BY clause: optional. When you delete, the rows in the table are deleted in the order specified in the clause.

WHERE clause: optional. Indicates that the deletion condition is qualified for the delete operation, and if the clause is omitted, all rows in the table are deleted.

LIMIT clause: optional. Used to tell the server the maximum value of the deleted row before the control command is returned to the client.

Example 1: delete all data in the table

Delete all data in the tb_courses table

Mysql > DELETE FROM tb_students;Query OK, 3 rows affected (0.12 sec) mysql > SELECT * FROM tb_students;Empty set (0.00 sec)

Example 2: delete data in a table according to conditions

In the tb_students table, delete the record with id 4

Mysql > DELETE FROM tb_students-> WHERE id=4;Query OK, 1 row affected (0.00 sec) mysql > SELECT * FROM tb_students +-+ | id | name | dept_id | age | sex | height | login_date | +- -+-+ | 1 | Dany | 1 | 25 | F | 2015 | 09-10 | 2 | Green | 3 | 23 | F | 2016-10-22 | 3 | Henry | 2 | 23 | M | 2015-05-31 | 5 | Jim | 1 | 24 | M | 2016-01-15 | 6 | John | | 2 | 21 | M | 2015 | 11-11 | | 7 | Lily | 6 | 22 | F | 2016-02-26 | 8 | Susan | 4 | 23 | F | 170 | 2015-10-01 | +-+-- -+ 4 rows in set (0.00 sec)

As can be seen from the running results, the record with an id of 4 has been deleted.

The above is the database delete statement delete what is the role of all the content, thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report