Delete 如何既是 DDL 又是 DML 语句

How can Delete be both a DDL and a DML statement

我目前正在阅读 Microsoft 官方书籍 'Database Administration Fundamentals' 以准备参加它的考试。

我了解 DDL 和 DML 是什么,但 Microsoft 将 DELETE 显示为 DDL 和 DML 语句。我用谷歌搜索了这个,但我无法证实或否认这一点。

一个很好的参考是这个问题:What is DDL and DML 它将它显示为 DML。以下是书中的片段:

Data Manipulation Language (DML) is the language element that allows you to use the core statements INSERT, UPDATE, DELETE, and MERGE to manipulate data in any SQL Server tables. Core DML statements include the following: • SELECT: Retrieves rows from the database and enables the selection of one or many rows or columns from one or many tables in SQL Server. • INSERT: Adds one or more new rows to a table or a view in SQL Server. • UPDATE: Changes existing data in one or more columns in a table or view. • DELETE: Removes rows from a table or view. • MERGE: Performs insert, update, or delete operations on a target table based on the results of a join with a source table.

the six main DDL statements are as follows: • USE: Changes the database context. • CREATE: Creates a SQL Server database object (table, view, or stored procedure). • ALTER: Changes an existing object. • DROP: Removes an object from the database. • TRUNCATE: Removes rows from a table and frees the space used by those rows. • DELETE: Remove rows from a table but does not free the space used by those rows removed.

这本书是否过时/错误。有人可以帮助阐明这一点吗?我看到完整的 DDL 和 DML 语句的列表相互矛盾。

我同意你的看法,DELETE是DML。此外,我敢说,TRUNCATE 也应该被视为 DML,因为在逻辑上等同于 DELETE 语句。 TRUNCATEDROPCREATE 这一事实在我看来不足以证明将其分配给 DDL,因为两者一起作为一个原子操作执行,不会影响数据库的架构。