03 June 2016

Drop vs Truncate vs Delete in SqlServer

Drop Command: If we want to destroy the existing tables present in the database we use the Drop Command.

DROP TABLE Students

Truncate Command: Removes all rows from a table. TRUNCATE TABLE is functionally the same as the DELETE statement with no WHERE clause specified.

TRUNCATE TABLE Students

The difference between Truncate and Delete is:

  • Truncate table is faster in execution.

  • Truncate will reset the identity function if present on the table to initial value again which will not happen in delete.


 

No comments: