1. Home
  2. Data Science
  3. SQL for Data Analysis
  4. Which statement about TRUNCATE compared with DELETE is…

Added 30 Nov -0001

Which statement about TRUNCATE compared with DELETE is correct?

  1. TRUNCATE accepts a WHERE clause but is slower than DELETE, because it scans the whole table row by row
  2. Both fire row-level triggers once per removed row, so auditing behaves exactly the same for the two statements here
  3. DELETE cannot be rolled back in any database, while TRUNCATE always can, because it is DDL and not DML
  4. TRUNCATE removes all rows in one operation, cannot take a WHERE clause and fires no row-level delete triggers Correct answer

Correct answer

D. TRUNCATE removes all rows in one operation, cannot take a WHERE clause and fires no row-level delete triggers

15 views

MCQSEXAM

Explanation

TRUNCATE versus DELETE: TRUNCATE is a DDL-style bulk operation that deallocates pages, allows no WHERE clause, fires no per-row DELETE triggers and in many engines resets identity sequences. DELETE is DML, logs each row, supports WHERE, fires triggers and is fully rollback-able where transactions apply. Because TRUNCATE takes an exclusive lock, it is unsuitable while concurrent readers are active.

Reference

Asked in: NTS, PPSC IT, Interviews

Preparing for an exam?

Doubts & discussion

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

Ask a doubt about this MCQ

Shown after review. No links please.

More SQL for Data Analysis MCQs

Practise all SQL for Data Analysis MCQs

Similar MCQs