Consider a table employees with 100 rows. What will be the number of rows in the table after executing the following commands?
1. TRUNCATE TABLE employees;
2. DROP TABLE employees;
Choose the correct pair of row counts after each command.
Think about what happens to the table structure after each command.
TRUNCATE removes all rows but keeps the table structure intact, so row count becomes 0. DROP removes the entire table, so it no longer exists.
Which statement correctly describes the transaction behavior of DROP TABLE and TRUNCATE TABLE in MySQL?
Consider if these commands can be undone inside a transaction.
In MySQL, both DROP TABLE and TRUNCATE TABLE are DDL statements that cause an implicit commit before and after execution. Neither can be rolled back within a transaction.
Which of the following SQL commands correctly removes all rows from a table orders but keeps the table structure intact?
Think about which command clears data but does not delete the table.
TRUNCATE TABLE removes all rows quickly and keeps the table. DROP TABLE deletes the table. DELETE FROM is valid syntax but slower. DELETE TABLE and REMOVE ALL FROM are invalid syntax.
You want to remove all rows from a large table logs. Which command is generally faster and why?
Consider how each command handles logging and data removal.
TRUNCATE is faster because it deallocates data pages and does minimal logging. DELETE logs each row deletion, making it slower. DROP removes the table entirely, not just rows. DELETE * is invalid syntax.
You try to run TRUNCATE TABLE orders; but get an error about foreign key constraints. What is the cause?
Think about how foreign keys affect data removal commands.
MySQL does not allow TRUNCATE on tables referenced by foreign keys because it bypasses row-level checks. You must drop or disable foreign keys or use DELETE instead.