Which SQL DDL command is analogous to the DML delete command? I think it's truncate but could it be drop?
-
I'm trying to figure out what your question really means. – Gordon Linoff Oct 05 '15 at 21:47
-
Mureinik is correct. `TRUNCATE` wipes off the data in a table. `DELETE` can do that also, although there are [differences in what happens in the background](http://stackoverflow.com/questions/20559893/comparison-of-truncate-vs-delete-in-mysql-sqlserver). – zedfoxus Oct 05 '15 at 21:52
-
What you are trying to do? – Jean Jung Oct 05 '15 at 21:57
3 Answers
drop [something]
removes an object. truncate
removes all the rows from a given table. In that sense, you could say it's analogous to a delete
operation.

- 297,002
- 52
- 306
- 350
From MSDN:
DELETE
Removes one or more rows from a table or view in SQL Server.
TRUNCATE TABLE
is similar to the DELETE
statement with no WHERE
clause; however, TRUNCATE TABLE
is faster and uses fewer system and transaction log resources.
Use DROP
statements to remove existing entities. For example, use DROP TABLE
to remove a table from a database.

- 1,616
- 1
- 21
- 31
TRUNCATE Table used to quickly delete all records in a table and TRUNCATE Never changes the Structure Of a Table while it removes table's data. It removes the spaces that we have allotted to table records.
Drop command is used to flush the table. Drop command is used when we don't need the data.

- 1,307
- 6
- 26
- 51
-
Are you certain you want to state that `TRUNCATE TABLE` is DML? Check out [MSDN](https://msdn.microsoft.com/en-us/library/ff848799.aspx?f=255&MSPPError=-2147217396) and [this question](http://dba.stackexchange.com/questions/36607/why-is-truncate-ddl) – Morpheus Oct 08 '15 at 18:27
-
-