美文网首页
truncate命令

truncate命令

作者: 做个北漂吧 | 来源:发表于2019-10-15 11:15 被阅读0次

1. truncate用法

TRUNCATE [TABLE] tbl_name

truncate 用来清空一个数据库表的所有数据。

2.官方解释

Logically, TRUNCATE TABLE is similar to a DELETE statement that deletes all rows, or a sequence of DROP TABLE and CREATE TABLE statements. To achieve high performance, it bypasses the DML method of deleting data. Thus, it cannot be rolled back, it does not cause ON DELETE triggers to fire, and it cannot be performed for InnoDB tables with parent-child foreign key relationships.

上面的意思就是说:从逻辑上讲,TRUNCATE TABLE类似于删除所有行的DELETE语句,或类似于DROP TABLE并CREATE TABLE语句的序列。为了获得高性能,它绕过了删除数据的DML方法。因此,它不能回滚,也不会触发ON DELETE触发器,并且不能在具有父子外键关系的InnoDB表上执行。

DML:数据操纵语言DML(Data Manipulation Language),用户通过它可以实现对数据库的基本操作。

相关文章

  • SQLite Truncate Table

    SQLite Truncate Table 在 SQLite 中,并没有 TRUNCATE TABLE 命令,但可...

  • truncate命令

    树 1. truncate用法 truncate 用来清空一个数据库表的所有数据。 2.官方解释 Logicall...

  • 重置MySQL数据表

    重置mysql 数据表,id重置 使用mysql的truncate命令,用法:truncate table 表名;...

  • DML DDL

    增删改查是DML命令,create-drop-truncate是DDL命令。 ENGINE=InnoDB AUTO...

  • 「SQLite学习笔记」Truncate Table

    在 SQLite 中,并没有 TRUNCATE TABLE 命令,但可以使用 SQLite 的 DELETE 命令...

  • 如何在Linux中使用 Truncate 命令

    Truncate命令[https://www.linuxcool.com/]通常用于将文件缩小或扩展到指定的大小。...

  • 第15讲 mysql积累

    mysql清空表数据后让自增ID仍从空位开始的方法 1、清空表时使用truncate命令,而不用delete命令m...

  • MySQL基础回顾

    最近准备一下面试,所以,重新走一遍基础。 1.删除命令 使用truncate 命令,清除表内数据,却不删除表结构...

  • 解决Mysql cannot truncate a table

    问题 truncate xx时,提示cannot truncate a table refrenenced in ...

  • 清空所有统计表

    truncate table tj_daily_chn; truncate table tj_daily_grp;...

网友评论

      本文标题:truncate命令

      本文链接:https://www.haomeiwen.com/subject/pschpctx.html