To delete data from a table:
- TRUNCATE TABLE wp_comments;
- Delete * from wp_comments;
The difference between the two methods:
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