1. Home
  2. Computer Science MCQs
  3. MySQL
  4. What is the difference between DELETE and TRUNCATE in MySQL?

Added 27 Jan 2024

What is the difference between DELETE and TRUNCATE in MySQL?

  1. DELETE is faster, while TRUNCATE is more secure.
  2. DELETE allows you to specify conditions, while TRUNCATE deletes all rows.  Correct answer
  3. DELETE can be rolled back, while TRUNCATE cannot.
  4. There is no difference between these commands.

Correct answer

B. DELETE allows you to specify conditions, while TRUNCATE deletes all rows. 

20 views

MCQSEXAM

Explanation

DELETE lets you specify conditions with WHERE, while TRUNCATE removes all rows. DELETE is a DML command that removes rows one by one and can be rolled back inside a transaction; TRUNCATE is DDL — it empties the table at once, resets AUTO_INCREMENT and is much faster on large tables.

Neither removes the table structure; that is the job of DROP.

Keep preparing with more Database Management Systems MCQs on MCQsExam.com.

Doubts & discussion

Not sure why the answer is B? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More MySQL MCQs

Practise all MySQL MCQs

Similar MCQs