gpt4 book ai didi

sql - Delete 如何既是 DDL 又是 DML 语句

转载 作者:行者123 更新时间:2023-12-02 01:16:07 27 4
gpt4 key购买 nike

我目前正在阅读 Microsoft 官方书籍“数据库管理基础”,以准备参加它的考试。

我了解 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,因为两者一起执行作为一个原子操作,不影响数据库的架构。

关于sql - Delete 如何既是 DDL 又是 DML 语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42536536/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com