Friday 15 November 2013

Difference between truncate and drop command in SQL

                 Difference between truncate and drop command in SQL


Both truncate and delete are DDL statements and changes done by both can't be reverted. Following are the main differences between both:

Truncate Command:
  • Truncate removes all the records from the table/view
  • Truncate command is used to remove data from the table
  • The schema for the table remains as it is
  • It does not effect relationship between tables
Drop Command:

  • Drop command is used to remove and object from the database
  • The object(table/view/indexes,etc) is completely removed from the database
  • The schema is also removed
  • All the relationship for that object is removed and if we need that object to use again then we will have to develop it from scratch

No comments:

Post a Comment