问题
I am currently reading the offical Microsoft book 'Database Administration Fundamentals' in preparation to sitting it's exam.
I understand what DDL and DML are but Microsoft show DELETE as being both a DDL and DML statement. I have googled this but I cannot anything that confirms or denies this.
A good reference to this is the question: What is DDL and DML Which shows it as a DML. Below is the segments from the book:
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.
Is the book out of date/ wrong. Can someone help shed light on this I see conflicting lists of what are the full DDL and DML statements.
回答1:
I agree with you, DELETE
is DML. Moreover, I dare say, TRUNCATE
should also be considered DML, since logically is equivalent to a DELETE
statement. The fact that TRUNCATE
is a DROP
and CREATE
is not enough in my opinion to justify assigning it to DDL, since the two together, carried out as one atomic operation, do not affect the schema of the database.
来源:https://stackoverflow.com/questions/42536536/how-can-delete-be-both-a-ddl-and-a-dml-statement