[Tips] difference between truncate and delete and usage of truncate

Source: Internet
Author: User

Truncate and delete have the following differences:
1. truncate is very fast on various tables, whether large or small. If the rollback command Delete is used, the truncate command is not used.
2. truncate is a DDL language. Like all other DDL languages, it will be implicitly submitted and cannot use the rollback command for truncate.
3. truncate will reset the high horizontal line and all indexes. When you completely browse the entire table and index, the table after the truncate operation is much faster than the table after the delete operation.
4. truncate cannot trigger any Delete trigger.
5. You cannot grant anyone the permission to clear tables of others.
6. After the table is cleared, the index of the table and the table is reset to the initial size, while the delete statement is not.
7. The parent table cannot be cleared.

Truncate table (schema) table_name drop (reuse) Storage
By default, drop storage will shorten the table and table index when drop storage is used, contract the table to the minimum range, and reset the next parameter. Reuse storage does not shorten the table or adjust the next Parameter

Use reuse storage in special circumstances
 
A typical example of practical application:
You use sqlldr to load a 10 million-record data table, but when loading more than half of the data table, you find that there is a problem,
In this case, you want to clear the table and reload it.
So it is better to reuse storage, so that you do not need to find free space again for re-loading.

 

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.