树
1. truncate用法
TRUNCATE [TABLE] tbl_name
truncate 用来清空一个数据库表的所有数据。
2.官方解释
Logically,
TRUNCATE TABLE
is similar to aDELETE
statement that deletes all rows, or a sequence ofDROP TABLE
andCREATE TABLE
statements. To achieve high performance, it bypasses the DML method of deleting data. Thus, it cannot be rolled back, it does not causeON DELETE
triggers to fire, and it cannot be performed forInnoDB
tables with parent-child foreign key relationships.
上面的意思就是说:从逻辑上讲,TRUNCATE TABLE类似于删除所有行的DELETE语句,或类似于DROP TABLE并CREATE TABLE语句的序列。为了获得高性能,它绕过了删除数据的DML方法。因此,它不能回滚,也不会触发ON DELETE触发器,并且不能在具有父子外键关系的InnoDB表上执行。
DML:数据操纵语言DML(Data Manipulation Language),用户通过它可以实现对数据库的基本操作。
网友评论