截断 DDL 或 DML 命令

Truncate a DDL or DML command

我一直都知道 TRUNCATE 是一个 DDL 命令,但 Microsoft 文档让我感到困惑。

This link says that TRUNCATE is a DDL command and this 表示 TRUNCATE 是一个 DML 命令

另外,DDL和DML的说明在不同的数据库中有区别吗?前任。甲骨文,MySql等

就我个人而言,我会说 TRUNCATE 是一个 DML 命令;您正在使用它来操纵数据,而不是更改定义。

文档中有一些地方存在冲突,主要是因为它们比其他文档更旧。他们甚至无法决定 CASE 是语句还是表达式。

嗯,TRUNCATE TABLE,正如 Microsoft 文档中所述,它类似于 DELETE(他们自己承认)。并且 DELETE 是 DML,因此,TRUNCATE TABLE 也应该是 DML。

也许写第一篇文章的人放错了。或者 he/she 可能想指出这是一个使用 DDL 时要谨慎的命令。

我必须承认这是我第一次看到该命令,我不知道它是否包含在 SQL 标准中。

维基百科说 TRUNCATE 是 DML:

In SQL, the TRUNCATE TABLE statement is a Data Manipulation Language (DML) operation that marks the extents of a table for deallocation (empty for reuse). The result of this operation quickly removes all data from a table, typically bypassing a number of integrity enforcing mechanisms. It was officially introduced in the SQL:2008 standard.

https://en.wikipedia.org/wiki/Truncate_(SQL)

事实是TRUNCATE是一个DDL命令。您提供的第一个link是正确的,第二个是昨天fixed

Wikipedia 也将其定义为 DDL 命令,但在 12 February 2018‎ (and properly reverted on 3 April 2018‎) 上进行的错误编辑使其在一段时间内不是这样。