What are the differences between DELETE, TRUNCATE, and DROP commands in T-SQL?

1 Answers
Answered by suresh

Differences between DELETE, TRUNCATE, and DROP commands in T-SQL

Differences between DELETE, TRUNCATE, and DROP commands in T-SQL

DELETE:

  • DELETE command is used to remove specific rows from a table based on a condition.
  • It is a DML (Data Manipulation Language) command.
  • DELETE operations can be rolled back using a transaction.

TRUNCATE:

  • TRUNCATE command is used to remove all the rows from a table, but the table structure remains intact.
  • It is a DDL (Data Definition Language) command.
  • TRUNCATE operations cannot be rolled back.
  • TRUNCATE is faster than DELETE as it does not log individual row deletions.

DROP:

  • DROP command is used to delete an entire table including its structure from the database.
  • It is a DDL (Data Definition Language) command.
  • DROP operations cannot be rolled back.
Answer for Question: What are the differences between DELETE, TRUNCATE, and DROP commands in T-SQL?