Modifying and managing database tables is an essential skill when working with MySQL. This quiz will test your knowledge of key concepts such as altering table structures, adding and deleting columns, renaming tables, and duplicating data. You will also explore how to safely modify table data while preserving constraints and avoiding errors. Answer the following questions to assess your understanding of updating and managing MySQL tables effectively.
1.
How can you rename a column in MySQL?
2.
What is the correct way to change a column's data type?
3.
Which SQL statement renames an existing table?
4.
What will the following SQL command do?
ALTER TABLE product ADD on_sale BOOL;
5.
Which keyword is used to add a new column to a table?
6.
Which statement ensures that the duplicated table retains its structure, including constraints?
7.
Which keyword is used to move a column to a specific position in a table?
8.
If a table contains data and you attempt to shorten a column's length, what might happen?
9.
Which of the following is true about MySQL table modifications?
10.
Which SQL statement is used to modify the structure of an existing table?
11.
What happens to constraints like PRIMARY KEY when duplicating a table using the following statement?
CREATE TABLE new_table AS SELECT * FROM old_table;
12.
How can you duplicate a table in MySQL without copying its data?
13.
What will happen if you run the following statement?
ALTER TABLE product DROP COLUMN discount;
14.
Which statement correctly copies all data from one table to another after duplicating its structure?
15.
Which SQL statement permanently removes a table from the database?