Differences between Delete and truncate

Source: Internet
Author: User

Differences
1. The conditions can be written after the delete from statement, but not after the truncate statement.
2. The delete from record is deleted one by one, and each deleted line of record is logged, while the truncate deletes the entire page at a time. Therefore, only the page is released from the day to day. In short, delete from updates, basically no truncate, less transaction log Space
3. After deleting an empty table from the delete from statement, an empty page is retained.
4. When the delete statement is executed using the row lock, the rows in the table are locked for deletion. Truncate always locks tables and pages, rather than locking rows.
5. If the auto-increment ID column generated by identity is deleted from, it will still increase from the last number, that is, the seed will remain unchanged. After truncate, the seed will resume the initial
6. Truncate does not trigger the delete trigger, because the truncate operation does not record the deletion of each row

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.