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 difference between deleting table data and deleting table structure in SQL

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 the SQL delete table data and delete table structure what is the difference, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.

In SQL, delete table data and delete table structure: 1, delete table data, the table structure is still there, and delete table structure refers to delete the entire table, including structure and data; 2, different commands, delete table data [delete from table name], and delete table structure is [drop table table name].

The difference between deleting table data and deleting a table structure in SQL:

1. The definition is different.

To delete the contents of a table is to delete the data of the table. The structure of the watch is still there.

To delete the structure of a table is to delete the entire table, including structure and data.

2. Different orders.

Delete the data from the table:

Truncate table name

Or

Delete from name

Delete the table structure:

Drop table name

Extended data:

Truncate: delete the content, free up space without deleting the definition (preserve the data structure of the table). Truncate cannot delete row data. If you want to delete it, you have to empty the table.

The delete:delete statement is used to delete rows from a table. The delete statement performs deletions by deleting one row at a time from the table and saving the deletion of that row in the log as a transaction record for rollback operations.

Truncate and delete without where: delete only the data, not the table structure (definition).

If you want to keep the identity count value, use delete instead. Use the drop table statement if you want to delete the table definition and its data.

Drop: delete content and definitions to free up space. To put it simply, remove the whole watch. Data cannot be added in the future unless a new table is added.

The drop statement removes the constraints on which the structure of the table is dependent (constrain, trigger, index); stored procedures / functions that depend on the table will be retained, but their state will change to: invalid.

Thank you for reading this article carefully. I hope the article "what's the difference between deleting table data and deleting table structure in SQL" shared by the editor is helpful to everyone. At the same time, I also hope you can 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.

Share To

Database

Wechat

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

12
Report