In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces how to write the sql deletion sentence, which has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, let the editor take you to understand it.
Sql delete statement: 1, delete statement is used to delete rows in the table; 2, drop [delete table] delete content and definition, free up space; 3, truncate [clear data in table], delete content, free space but not delete definition.
Sql delete statement:
1. The delete statement is used to delete rows from the table. The delete statement performs a delete by deleting a row from the table each time, while saving the deletion of that row in the log as a transaction record
Syntax: DELETE FROM table name WHERE column name = value
For example, delete the student information named Zhang Sanfeng in the student table-delete from studentwhere name=' Zhang Sanfeng'
2. Drop (delete table): delete content and definition to free up space. To put it simply, get rid of the whole watch. It is impossible to add new data in the future unless you add a new table.
The drop statement removes the constraint (constrain) on which the structure of the table is dependent (constrain), the trigger (trigger) index (index); stored procedures / functions that depend on the table will be retained, but their state will change to: invalid.
3. Truncate (emptying the data in the table): delete the content, free the space but not delete the definition (retain the data structure of the table). Unlike drop, it just empties the table data.
Note: truncate cannot delete row data. If you want to delete it, you have to empty the table.
Extended data:
In database operation, delete table and delete table data are often used. In practical application, the difference between them is clear.
When you no longer need the watch, use drop
When you still want to keep the table, but delete all records, use truncate
When you want to delete some records (always with a WHERE clause), use delete.
Comparison of truncate and delete:
1. Truncate table is functionally the same as a delete statement without a WHERE clause: both delete all rows in the table.
2. Truncate is faster than delete and uses less system and transaction log resources.
3. The table after truncate operation is much faster than that after Delete operation.
Thank you for reading this article carefully. I hope the article "how to write sql deletion sentences" shared by the editor will be helpful to everyone. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.