Difference between truncate table and delete, truncatetable
Truncate table requires the drop table permission, which completely clears a table. Logically, the truncate table is the same as the delete table, or the drop table + create table is the same. Using truncate table to delete full table data is faster than deleting. The truncate table is used to clear data. rollback is not allowed and is not restricted by the foreign key constraints between tables. Truncate is a DDL statement and delete is a DML statement. The differences between the two are as follows: 1. truncate is a mail drop table + create table, which is much faster than deleting a row of data using delete, especially clearing Big Data Tables. 2. truncate is a type of implicit commit, so rollback is not allowed. 3. If the current table has foreign key constraints, the truncate table can clear all data in the table, without the foreign key constraints. 4. Use truncate table to set the auto-increment ID to zero, and delete will not. 5. When a partition table is used, the table is truncated to save the partition. That is, the data and index files are deleted and re-created, and the partition definition (. par) files are not affected. 6. The truncate table statement does not call the delete trigger.
Refer:
Http://dev.mysql.com/doc/refman/5.7/en/truncate-table.htmlhttp://dev.mysql.com/doc/refman/5.6/en/optimizing-innodb-ddl-operations.html
Truncate table and delete * from
There are two main differences. Truncate is the overall deletion, and delete is the one-by-one deletion. 2. truncate does not write server logs, and delete writes to server logs. This is why truncate is faster than delete. Therefore, the impact is as follows: 1. Truncate is 2 faster. Truncate does not activate trigger3. Truncate reset Identity
Question: What is the difference between truncate table and DELETE when deleting all records of the entire TABLE?
1. DELETE
・ DML Language
Rollback is supported.
Conditions can be deleted with conditions.
Delete from Table Name
WHERE condition
2. TRUNCATE TABLE
・ DDL Language
Rollback failed
By default, all table content is deleted.
The restore operation is faster than the delete operation.
Truncate table name