How to delete tables with large data volumes in DB2

Source: Internet
Author: User

The delete table command is often used when DB2 deletes data. However, the delete table command still has some limitations. It is not perfect when processing a large amount of data.

When you use the delete table command to DELETE data in DB2, this operation deletes the TABLE records one by one and records them in the active transaction logs. When the data volume in the table is large, if the transaction log of the activity is not large enough, the transaction log is full and the log is rolled back. Even if the transaction log of the activity is large enough, it takes a lot of time for DB2 to delete tables with a large amount of data. This problem can be solved by importing an empty file as a data file) and replacing the REPLACE table. For example

Import from/dev/null of del replace into target table name

In this way, transaction logs only record this command and immediately release the occupied space, instead of scanning records one by one like DB2 data deletion commands, this is similar to dropping the table and then creating a table that is identical but has no data.

For a table in the DMS tablespace, the DB2 data deletion command scans records one by one, and the occupied record space is still marked as used by the table without immediately releasing the space, you must use the REORG command to release the remaining space. Use list tablespace show detail to compare the remaining space in the TABLESPACE after the two commands are executed.

Using the LOAD command and the REPLACE parameter can achieve the effect similar to the IMPORT command and the REPLACE, but because the LOAD itself does not remember the log, for recoverable databases, after LOAD is complete, we recommend that you perform online backup immediately. In contrast, the IMPORT command and REPLACE operations are simpler.

In windows, the following sentence is implemented.
Import from c: \ empty.txt of del replace into target table name
 

DB2 index design guidelines

Visualize DB2 Spatial Data

How to create a cross-database view in DB2

Several useful methods for updating the execution plan of DB2

Manually install DB2 on Linux 9

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.