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 are the reasons for the slow deletion of fields from large tables in the database?

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

Share

Shulou(Shulou.com)05/31 Report--

Editor to share with you what are the reasons for the slow deletion of large tables in the database. I hope you will gain something after reading this article. Let's discuss it together.

Due to the production environment, the DG architecture is used, so with the assistance of database colleagues, using the snapshot function of DG backup library, a real operation is performed in the production environment. Although the operation is different from the main database operation, the only difference is that there is no request pressure, which is equivalent to stopping the application, but it can still explain some problems.

The whole delete operation, the execution time, is about 30 minutes. Through the 10046 trace, you can see the waiting event, mainly like the following

This article mentions this mistake.

Https://blog.csdn.net/u011116642/article/details/51540314

Someone even took a test.

1. Set the column to unused

ALTER TABLE test1 SET UNUSED COLUMN Tablespace_name

two。 Delete unused column

ALTER TABLE test1 DROP UNUSED COLUMN CHECKPOINT 5

Force the database shutdown with shutdown abort before the execution is finished (if you use shutdown immediate, you will not see the effect, it will wait until the execution is finished before shutting down the database)

3. Restart the database, check the test1 table, and report an error

4. Continue to delete undeleted columns

ALTER TABLE test1 DROP COLUMNS continue

5. After the execution is finished, query the test1 table again and OK it.

two。 You can try to delete it logically, then physically delete it, that is, set it to unused online, wait for the maintenance window, and then delete this field, as in the following article

Https://blog.csdn.net/caimaohua/article/details/4264040

3. Use online redefinition to delete fields, as described in the following article

Http://m.blog.itpub.net/17203031/viewspace-772500/

Https://blog.csdn.net/qq_33879355/article/details/78578175

4. If there is downtime, you can use CTAS to rebuild the table and delete the fields indirectly.

To solve this problem, we have adopted the fifth method, that is, do not move this field, as a backup field, if you want to add a field for new requirements in the future, you will directly change this field, of course, there are some premises.

1. The reference to this field in the application needs to be deleted, such as the insert operation, and the field name needs to be deleted, otherwise there will be a problem.

two。 The type of the new field should be compatible with this field type. For example, this field is VARCHAR2, and the new field needs DATE, so it cannot be changed directly.

After reading this article, I believe you have a certain understanding of "what are the reasons for the slow deletion of fields from large tables in the database". If you want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

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