Delete data in DB2

Source: Internet
Author: User

---- Start

Everyone is familiar with how to delete data. We use this to write:

Delete from <table_name> where <condition>; 

In fact, this write performance is not good, especially when you delete a large amount of data, to achieve better performance, you can use the following method:

Delete from <br/> (<br/> select * from <table_name> where <condition> <br/> ); 

What should I do if I want to delete all the data in a table? Some people may say that this is simple. simply remove the WHERE clause. Correct answer,This is a method. When the data volume is large, it takes a long time to delete the data. Someone may drop the table first and then create the table,This is the second method.This process is fast but troublesome. ActuallyMethod 3,It is faster and simpler, as shown below:

Alter table <table_name> activate not logged initially with empty table 

It is solemnly stated that after the preceding statements are used, the operations on the table will not be recorded, and there may be problems during recovery, so it is particularly suitable for temporary tables. The preceding statements must be used with caution. I am not responsible for any consequences.. Of course, there are other methods, but thatIt's not SQL. It's a DB2 command.We will not introduce it here.

 

--- For more information, see:DB2 SQL

----Statement: indicate the source for reprinting.

---- Last updated on 2009.12.4

---- Written by shangbo on 2009.9.25

---- End

 

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.