0
0
SQLquery~20 mins

TRUNCATE vs DELETE vs DROP in SQL - Practice Questions

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Master of TRUNCATE vs DELETE vs DROP
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
Difference in row count after DELETE vs TRUNCATE

Consider a table Employees with 1000 rows. What will be the number of rows after running the following SQL commands separately?

1. DELETE FROM Employees;
2. TRUNCATE TABLE Employees;

Choose the correct pair of row counts after each command.

AAfter DELETE: 1000 rows, After TRUNCATE: 0 rows
BAfter DELETE: 0 rows, After TRUNCATE: 0 rows
CAfter DELETE: 0 rows, After TRUNCATE: 1000 rows
DAfter DELETE: 1000 rows, After TRUNCATE: 1000 rows
Attempts:
2 left
💡 Hint

Both DELETE and TRUNCATE remove all rows, but their behavior differs in other ways.

🧠 Conceptual
intermediate
2:00remaining
Transaction behavior of DELETE vs TRUNCATE

Which statement correctly describes the transaction behavior of DELETE and TRUNCATE commands?

ABoth DELETE and TRUNCATE can be rolled back
BNeither DELETE nor TRUNCATE can be rolled back
CDELETE can be rolled back, TRUNCATE cannot be rolled back
DDELETE cannot be rolled back, TRUNCATE can be rolled back
Attempts:
2 left
💡 Hint

Think about whether these commands are logged in transactions.

📝 Syntax
advanced
2:00remaining
Syntax error in DROP command

Which of the following DROP commands will cause a syntax error?

ADROP TABLE Employees;
BDROP TABLE IF EXISTS Employees;
CDROP Employees;
DDROP DATABASE CompanyDB;
Attempts:
2 left
💡 Hint

Check the correct syntax for dropping tables.

optimization
advanced
2:00remaining
Performance difference between DELETE and TRUNCATE

Which statement best explains why TRUNCATE is usually faster than DELETE when removing all rows from a large table?

ABoth commands perform the same operations internally, so speed is identical
BTRUNCATE removes rows one by one, DELETE removes all rows at once
CDELETE deallocates data pages without logging, TRUNCATE logs each row deletion
DTRUNCATE deallocates data pages without logging individual row deletions, DELETE logs each row deletion
Attempts:
2 left
💡 Hint

Think about how logging affects performance.

🔧 Debug
expert
2:00remaining
Effect of DROP on table and data

After running DROP TABLE Employees;, what will happen if you try to query SELECT * FROM Employees;?

ARaises an error because the table no longer exists
BReturns zero rows because table is empty
CReturns all rows from Employees table
DReturns metadata about the Employees table
Attempts:
2 left
💡 Hint

Think about what DROP does to a table.