difference between truncate delete and drop in SQL Server

difference between TRUNCATE, DELETE and DROP in SQL Server

DELETE Command

 1. DELETE is a DML command.
 2. DELETE is more slower than TRUNCATE command.
 3. DELETE maintain the logs before execute command. So its slower.
 4. In DELETE case, data rollback passable because it's maintain log file. 
 5. If we execute DELETE command that time tiger fired.
 6. In DELETE, we can use the WHERE clause.

      Example.  DELETE FROM AppLog WHERE LogId=1


TRUNCATE  Command

  1.   TRUNCATE is a DDL command.
  2.   TRUNCATE is more faster than DELETE command.
  3.   TRUNCATE not maintain logs so it's faster.
  4.   In TRUNCATE  case, data rollback not passable because it's not maintain log file .
  5.   If we execute TRUNCATE command that time tiger not fired.
  6.   In TRUNCATE , we can't use the WHERE clause.
     Example. TRUNCATE TABLE AppLog

DROP  Command

  1. DROP  is a DDL command.
  2. In case of DROP  command, TABLE delete permanently that menace all the table's  rows, indexes and privileges will  be removed from database.

  Example. DROP TABLE AppLog

ANIL SINGH

Anil Singh is an author, tech blogger, and software programmer. Book writing, tech blogging is something do extra and Anil love doing it. For more detail, kindly refer to this link..
My Blogs - https://code-sample.com and https://code-sample.xyz
My Book1 - BEST SELLING ANGULAR BOOK (INCLUDING ALL VERSIONS 2, 4, 5, 6, 7)
My Book2 - ANGULAR 2 INTERVIEW QUESTIONS BOOK - Both Books are Available on WorldWide.

www.code-sample.com/. Powered by Blogger.