A

Admin • 832.10K Points
Coach

Q. What is the difference between DELETE and TRUNCATE in MySQL?

  • (A) DELETE removes the table; TRUNCATE removes a single row
  • (B) DELETE can be rolled back in a transaction if using InnoDB; TRUNCATE is DDL and may not be rollback-able and is faster
  • (C) DELETE resets AUTO_INCREMENT; TRUNCATE preserves AUTO_INCREMENT
  • (D) There is no difference
  • Correct Answer - Option(B)
  • Views: 27
  • Filed under category MySQL
  • Hashtags:

Explanation by: Admin
DELETE is DML and can be transactional (rollback) under InnoDB; TRUNCATE is treated as DDL in many MySQL versions, is faster, and typically resets AUTO_INCREMENT. Option 3 is reversed. Option 1 and 4 are incorrect.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.