The difference between the MySQL purge table (truncate) and the data (delete) in the Delete table

Source: Internet
Author: User
  1. TRUNCATE TABLE wp_comments;
  2. Delete * from wp_comments;

Where the table in the truncate operation can be omitted, the * in the delete operation can be omitted. Both of these are emptying the data in the Wp_comments table, but there are also differences, as follows:

  • Truncate is the overall deletion (faster), delete is deleted one by one (slower).
  • Truncate does not write server Log,delete write server log, that is, truncate efficiency than delete high reason.
  • Truncate does not activate the trigger (trigger), but resets the identity (identity column, self-increment field), which is equivalent to the self-increment column being set to the initial value, and again starting from 1, rather than the number of previous IDs. When delete is deleted, the identity is still recorded after the last record ID plus 1 that was deleted.
  • If you only need to delete some of the records in the table, you can only use the DELETE statement with the Where condition. DELETE from Wp_comments WHERE ...

The difference between the MySQL purge table (truncate) and the data (delete) in the Delete table

Related Article

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.