DELETE removes rows from a table based on a condition. If no condition is given, it removes all rows but keeps the table structure.
Click to reveal answer
intermediate
How is TRUNCATE different from DELETE?
TRUNCATE quickly removes all rows from a table without logging individual row deletions. It resets the table but keeps its structure.
Click to reveal answer
beginner
What happens when you use DROP on a table?
DROP completely removes the table and its data from the database. The table structure and all data are deleted permanently.
Click to reveal answer
intermediate
Which command is faster for removing all rows: DELETE or TRUNCATE?
TRUNCATE is faster because it does not log each row deletion and resets the table quickly.
Click to reveal answer
advanced
Can DELETE be rolled back in a transaction? What about TRUNCATE?
DELETE can be rolled back because it logs each row deletion. TRUNCATE may not be rolled back in some databases because it is a DDL operation.
Click to reveal answer
Which SQL command removes all rows but keeps the table structure intact?
ATRUNCATE
BDELETE
CALTER
DDROP
✗ Incorrect
TRUNCATE removes all rows quickly but keeps the table structure.
Which command permanently deletes the table and its data?
AUPDATE
BTRUNCATE
CDELETE
DDROP
✗ Incorrect
DROP removes the entire table and its data from the database.
Which command logs each row deletion and can be rolled back?
ATRUNCATE
BDROP
CDELETE
DCREATE
✗ Incorrect
DELETE logs each row deletion and supports rollback in transactions.
Which command is generally faster for removing all rows from a table?
ADROP
BTRUNCATE
CDELETE
DINSERT
✗ Incorrect
TRUNCATE is faster because it does not log individual row deletions.
After using DROP on a table, what remains in the database?
ANothing
BTable data only
CTable structure only
DBoth structure and data
✗ Incorrect
DROP removes both the table structure and data completely.
Explain the differences between TRUNCATE, DELETE, and DROP commands in SQL.
Think about what happens to the data and the table itself with each command.
You got /5 concepts.
When would you choose TRUNCATE over DELETE or DROP? Give a simple example.
Consider performance and table preservation.
You got /4 concepts.
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
Step 1: Understand the effect of TRUNCATE
TRUNCATE removes all rows quickly without logging each row deletion, but keeps the table structure.
Step 2: Compare with other commands
DELETE removes rows but logs each deletion, DROP deletes the entire table, and ALTER changes table structure.
Final Answer:
TRUNCATE -> Option A
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
Step 1: Recall DELETE syntax
The correct syntax to delete rows is DELETE FROM table_name; without the asterisk.
Step 2: Check other options
DELETE * FROM is invalid syntax, TRUNCATE and DROP are different commands.
Final Answer:
DELETE FROM Employees; -> Option C
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
Step 1: Understand TRUNCATE effect on data
TRUNCATE TABLE removes all rows quickly without logging each deletion but keeps the table structure intact.
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.
Final Answer:
All rows are removed quickly, but the table remains for new data. -> Option B
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
Step 1: Check command syntax
The syntax DELETE FROM Customers WHERE CustomerID = 10; is correct if the table and column exist.
Step 2: Identify error cause
If an error occurs, likely the column CustomerID is misspelled or missing, causing the error.
Final Answer:
The CustomerID column is misspelled or missing. -> Option A
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
Step 1: Understand the goal
The goal is to remove the table and all its data permanently from the database.
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.
Final Answer:
DROP TABLE Orders; because it deletes the table and all its data permanently. -> Option D
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 unknownstrongwhile earning +1 Grip toward your certificate.