0
0
MySQLquery~10 mins

DROP and TRUNCATE behavior in MySQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to remove the entire table named 'employees'.

MySQL
DROP TABLE [1];
Drag options to blanks, or click blank then click option'
Aemployee
Bstaff
Cemployee_list
Demployees
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong table name that does not exist.
Confusing DROP with TRUNCATE.
2fill in blank
medium

Complete the code to remove all rows from the 'orders' table but keep its structure.

MySQL
TRUNCATE TABLE [1];
Drag options to blanks, or click blank then click option'
Aorders
Border
Corder_list
Dorder_details
Attempts:
3 left
💡 Hint
Common Mistakes
Using DROP instead of TRUNCATE when only data removal is needed.
Using a wrong table name.
3fill in blank
hard

Fix the error in the code to delete all data from 'customers' but keep the table.

MySQL
DELETE FROM [1];
Drag options to blanks, or click blank then click option'
Acustomer
Bcustomers
Ccustomer_data
Dclient
Attempts:
3 left
💡 Hint
Common Mistakes
Using a singular table name that does not exist.
Confusing DELETE with DROP.
4fill in blank
hard

Fill both blanks to create a command that deletes all rows from 'products' quickly and resets auto-increment.

MySQL
TRUNCATE TABLE [1]; -- This [2] the table data and resets auto-increment
Drag options to blanks, or click blank then click option'
Aproducts
Bremoves
Cdeletes
Ddrops
Attempts:
3 left
💡 Hint
Common Mistakes
Using DROP instead of TRUNCATE.
Using 'deletes' or 'drops' in the comment which is less precise.
5fill in blank
hard

Fill all three blanks to write a command that deletes the 'sessions' table and then recreates it empty.

MySQL
DROP TABLE IF EXISTS [1];
CREATE TABLE [2] (id INT PRIMARY KEY AUTO_INCREMENT, user_id INT);
TRUNCATE TABLE [3];
Drag options to blanks, or click blank then click option'
Asessions
Dsession_data
Attempts:
3 left
💡 Hint
Common Mistakes
Using different table names in the commands.
Omitting the DROP or CREATE commands.