Differences between deleting all rows in a table using Delete and truncate

Source: Internet
Author: User
Delete from tablename
Truncate table tablename
All records in the table can be deleted --
I used to know this command, but I don't know how it works and its performance. Today I am reading a book and posting it to share it with you.

The delete statement deletes a row from the table each time, and saves the delete operation of the row as a transaction record in the log for rollback, you can also delete views of a table.
The truncate table deletes all data pages from the table at one time and does not store the individual deletion operation records in logs. Deleting rows cannot be recovered. In addition, table-related deletion triggers are not activated during the deletion process. The number of resources used for war is relatively small, and the execution speed is fast.
In addition, truncate table can only Delete tables, but cannot delete views.

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.