What's the difference between delete and truncate?

Source: Internet
Author: User

What's the difference between delete and truncate?

The way to delete data in a table is Delete,truncate,

They all delete the data in the table, not the table structure, delete the data from the entire table or delete the data from one or N of the table that satisfies the condition, and truncate can only delete the data from the entire table. And the truncate operation is called truncating the table.

Truncate action vs. delete operation

Operation

Rolling back

High watermark

Space

Efficiency

Truncate

No

Fall

Recovery

Fast

Delete

OK

Not change

Do not recycle

Slow

Truncate and delete have the following differences

1, truncate on all kinds of tables, whether large or small are very fast. If a rollback command delete is revoked, the truncate is not revoked.

2, truncate is a DDL language, like all other DDL languages, he will be implicitly submitted, not to truncate use rollback command.

3, TRUNCATE will reset the high-level line and all indexes. When you fully 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, can not give anyone the right to empty other people's table.

6. When the table is emptied, the table and table indexes are reset to their initial size, and delete cannot.

7, can not empty the parent table.

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.