Bird
Raised Fist0
SQLquery~20 mins

TRUNCATE vs DELETE vs DROP in SQL - Practice Questions

Choose your learning style10 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.

Practice

(1/5)
1. Which SQL command removes all rows from a table quickly but keeps the table structure intact?
easy
A. TRUNCATE
B. DELETE
C. DROP
D. ALTER

Solution

  1. Step 1: Understand the effect of TRUNCATE

    TRUNCATE removes all rows quickly without logging each row deletion, but keeps the table structure.
  2. Step 2: Compare with other commands

    DELETE removes rows but logs each deletion, DROP deletes the entire table, and ALTER changes table structure.
  3. Final Answer:

    TRUNCATE -> Option A
  4. Quick Check:

    Fast row removal keeping table = TRUNCATE [OK]
Hint: TRUNCATE clears all rows fast but keeps table [OK]
Common Mistakes:
  • Confusing DROP with TRUNCATE
  • Thinking DELETE is faster than TRUNCATE
  • Assuming ALTER removes data
2. Which of the following is the correct syntax to delete all rows from a table named Employees?
easy
A. TRUNCATE TABLE Employees;
B. DELETE * FROM Employees;
C. DELETE FROM Employees;
D. DROP TABLE Employees;

Solution

  1. Step 1: Recall DELETE syntax

    The correct syntax to delete rows is DELETE FROM table_name; without the asterisk.
  2. Step 2: Check other options

    DELETE * FROM is invalid syntax, TRUNCATE and DROP are different commands.
  3. Final Answer:

    DELETE FROM Employees; -> Option C
  4. Quick Check:

    Correct DELETE syntax = DELETE FROM [OK]
Hint: DELETE syntax has no * after DELETE keyword [OK]
Common Mistakes:
  • Using DELETE * instead of DELETE FROM
  • Confusing TRUNCATE with DELETE syntax
  • Using DROP to remove rows only
3. Given a table Products with 1000 rows, what will be the result after running TRUNCATE TABLE Products;?
medium
A. The table is deleted completely, including its structure.
B. All rows are removed quickly, but the table remains for new data.
C. Only rows matching a condition are deleted.
D. An error occurs because TRUNCATE requires a WHERE clause.

Solution

  1. Step 1: Understand TRUNCATE effect on data

    TRUNCATE TABLE removes all rows quickly without logging each deletion but keeps the table structure intact.
  2. Step 2: Check other options

    The table is deleted completely, including its structure. describes DROP, Only rows matching a condition are deleted. describes DELETE with condition, An error occurs because TRUNCATE requires a WHERE clause. is incorrect because TRUNCATE does not allow WHERE but does not error for missing WHERE.
  3. Final Answer:

    All rows are removed quickly, but the table remains for new data. -> Option B
  4. Quick Check:

    TRUNCATE clears rows, keeps table = All rows are removed quickly, but the table remains for new data. [OK]
Hint: TRUNCATE clears all rows fast, table stays [OK]
Common Mistakes:
  • Thinking TRUNCATE deletes the table
  • Expecting TRUNCATE to support WHERE clause
  • Confusing TRUNCATE with DELETE
4. You run the command DELETE FROM Customers WHERE CustomerID = 10; but get an error. Which of these is the most likely cause?
medium
A. The CustomerID column is misspelled or missing.
B. You used DELETE without specifying a table.
C. You cannot use WHERE with DELETE.
D. The table Customers does not exist.

Solution

  1. Step 1: Check command syntax

    The syntax DELETE FROM Customers WHERE CustomerID = 10; is correct if the table and column exist.
  2. Step 2: Identify error cause

    If an error occurs, likely the column CustomerID is misspelled or missing, causing the error.
  3. Final Answer:

    The CustomerID column is misspelled or missing. -> Option A
  4. Quick Check:

    Column error causes DELETE failure = The CustomerID column is misspelled or missing. [OK]
Hint: Check column names carefully if DELETE with WHERE fails [OK]
Common Mistakes:
  • Assuming DELETE cannot use WHERE
  • Ignoring table existence errors
  • Confusing syntax errors with data errors
5. You want to permanently remove a table named Orders and all its data from the database. Which command should you use and why?
hard
A. DELETE FROM Orders; because it removes all rows and keeps the table.
B. TRUNCATE TABLE Orders; because it quickly deletes all rows but keeps the table.
C. ALTER TABLE Orders DROP; because it removes the table structure.
D. DROP TABLE Orders; because it deletes the table and all its data permanently.

Solution

  1. Step 1: Understand the goal

    The goal is to remove the table and all its data permanently from the database.
  2. Step 2: Compare commands

    DELETE and TRUNCATE remove data but keep the table. ALTER TABLE DROP is invalid syntax. DROP TABLE removes the table and data permanently.
  3. Final Answer:

    DROP TABLE Orders; because it deletes the table and all its data permanently. -> Option D
  4. Quick Check:

    Remove table and data permanently = DROP TABLE [OK]
Hint: DROP removes table and data permanently [OK]
Common Mistakes:
  • Using DELETE or TRUNCATE to remove table
  • Trying ALTER TABLE DROP which is invalid
  • Confusing DROP with DELETE
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard