Which of the following statement is correct regarding the difference between TRUNCATE, DELETE and DROP command?

Category: SQLWhich of the following statement is correct regarding the difference between TRUNCATE, DELETE and DROP command?
Editor">Editor Staff asked 2 years ago

Which of the following statement is correct regarding the difference between TRUNCATE, DELETE and DROP command?
I. DELETE operation can be rolled back but TRUNCATE and DROP operations cannot be rolled back.
II. TRUNCATE and DROP operations can be rolled back but DELETE operations cannot be rolled back.
III. DELETE is an example of DML, but TRUNCATE and DROP are examples of DDL.
IV. All are an example of DDL.

  1. I and III
  2. II and III
  3. II and IV
  4. II and IV
1 Answers
Editor">Editor Staff answered 2 years ago

Answer:

  1. I and III

Explanation:
DELETE is used to remove existing records from the database. DELETE command is a DML statement so that it can be rolled back.
DROP is used to delete the whole table, including its structure. DROP is a DDL command that lost the data permanently, and it cannot be rolled back.
TRUNCATE is used to delete the whole records, but it preserves the table’s schema or structure. TRUNCATE is a DDL command, so it cannot be rolled back.
Hence, option A is the correct answer.