What is difference between drop table and truncate table?
Truncate Table | Drop-Table |
---|---|
It is a DDL Command | This command is used to remove a table from the database. |
It is executed using a table lock and the whole table is locked while removing all the records. | Using this, all the rows, indexes and other privileges shall also be removed. |
The WHERE clause cannot be used with TRUNCATE. | By using this command, no DML triggers shall be fired. |
It removes all rows within a table. | Once started, this operation cannot be rolled back again. |
Minimum logging required in the transaction log. Hence, it is more efficient. | It is also a DDL command. |
This command is used to remove all the data by re-allocating the data pages to store only table data and only using it for recording page deallocations. | Removes multiple table data definitions within a database. |
BY Best Interview Question ON 15 Jul 2020