The Delete command is a DML statement because it deletes data from table
The Truncate command is also Delete the Records from tables.
But how the Truncate command comes under DDL Statement??
Printable View
The Delete command is a DML statement because it deletes data from table
The Truncate command is also Delete the Records from tables.
But how the Truncate command comes under DDL Statement??
Where [COLOR="Blue"]DELETE [/COLOR]statement deletes rows from table matching specifications in [COLOR="blue"]WHERE [/COLOR]clause .
[COLOR="blue"]TRUNCATE [/COLOR]deallocates memory page(s) allocated for the specific table in memory and hence it is a DDL statement rather than DML.
Ofcourse [COLOR="Blue"]DELETE [/COLOR] can be executed with out using [COLOR="blue"]WHERE [/COLOR] calause to delete all the rows , however the page(s) are not deallocated .
Additional info : [COLOR="blue"]DELETE [/COLOR] statement is logged operation and hence can be rolled back where as [COLOR="blue"]TRUNCATE [/COLOR] is not and hence can not be rolled back
HTH :)
Regards,
Good answer from SQLTweety. Deserves applauds. :)
Glad I could help :)
Keep inventing.
Regards.
TRUNCATE TABLE handles table as an entity to clear all data from the specified table. It does not create log while deleting data from the table so it can not be rolled back. As it handles table it is DDL i.e Data Definition Language command.
Where as DELETE command deletes specified rows with WHERE condition so it is DML.
DELETE command creates log entry after deleting rows so can be rolled back.