MySQL Database Quiz Questions

Course Name:MySQL
Chapter Name:Chapter 5 - DDL (Data Definition Language)
Lesson Content Link:ALTER TABLE
Current Quiz Count:30
Progress
0%
Q1
Single Choice

Which of the following MySQL commands is used to add a new column to an existing table?

Q2
Single Choice

To change the data type of an existing column in MySQL, which clause of the ALTER TABLE statement is used?

Q3
Single Choice

Which of the following commands is used to rename a table in MySQL?

Q4
Single Choice

How would you add a new column age of type INT to an existing MySQL table named users?

Q5
Single Choice

Which statement would you use to drop the column age from the users table in MySQL?

Q6
Single Choice

To change the name of an existing column from age to years in the users table, which MySQL command would you use?

Q7
Single Choice

To add a UNIQUE constraint to the email column in the users table, which MySQL command would you use?

Q8
Single Choice

How would you add a foreign key constraint to the order_id column in the orders table referencing the id column in the customers table?

Q9
Single Choice

Which MySQL command would you use to modify the price column in the products table to have a default value of 0.0?

Q10
Single Choice

In MySQL, to change the storage engine of a table named transactions to InnoDB, which of the following commands would you use?

Q11
True / False

In MySQL, the ALTER TABLE statement can be used to add a new column to an existing table.

Q12
True / False

The ALTER TABLE statement in MySQL can be used to rename a column.

Q13
True / False

You can use the ALTER TABLE statement in MySQL to directly insert data into a table.

Q14
True / False

In MySQL, to change the data type of a column, the ALTER TABLE statement can be used with the MODIFY COLUMN clause.

Q15
True / False

MySQL allows adding multiple columns in a single ALTER TABLE statement.

Q16
True / False

To remove a primary key constraint from a column, you use the ALTER TABLE statement with the DROP PRIMARY KEY clause in MySQL.

Q17
True / False

The ALTER TABLE statement in MySQL can be used to change the storage engine of a table.

Q18
True / False

You can use the ALTER TABLE statement to add a foreign key constraint in MySQL without specifying the referenced table and column.

Q19
True / False

MySQL's ALTER TABLE statement can be used to rename an existing table.

Q20
True / False

In MySQL, using the ALTER TABLE statement to add a unique constraint to a column will automatically index that column.

Q21
Multiple Choice

Identify the correct ALTER TABLE statement to add a new column to an existing table.

SQL Code
ALTER TABLE employees
ADD COLUMN department_id INT;
Q22
Multiple Choice

Select the correct ALTER TABLE statement to change the data type of a column.

SQL Code
ALTER TABLE products
MODIFY COLUMN price DECIMAL(12, 2);
Q23
Multiple Choice

Choose the correct ALTER TABLE statement to rename a column in a table.

SQL Code
ALTER TABLE customers
CHANGE COLUMN full_name name VARCHAR(100);
Q24
Multiple Choice

Determine the correct ALTER TABLE statement to drop a column from a table.

SQL Code
ALTER TABLE orders
DROP COLUMN shipping_address;
Q25
Multiple Choice

Which ALTER TABLE statement correctly adds a UNIQUE constraint to a column?

SQL Code
ALTER TABLE users
ADD CONSTRAINT unique_email UNIQUE(email);
Q26
Multiple Choice

Identify the correct ALTER TABLE statement to add a foreign key constraint.

SQL Code
ALTER TABLE orders
ADD CONSTRAINT fk_customer
FOREIGN KEY (customer_id)
REFERENCES customers(customer_id);
Q27
Multiple Choice

Select the correct ALTER TABLE statement to rename an existing table.

SQL Code
ALTER TABLE inventory
RENAME TO products_inventory;
Q28
Multiple Choice

Determine the correct ALTER TABLE statement to add multiple columns to a table.

SQL Code
ALTER TABLE employees
ADD COLUMN department_id INT,
ADD COLUMN manager_id INT;
Q29
Multiple Choice

Which ALTER TABLE statement correctly drops a UNIQUE constraint?

SQL Code
ALTER TABLE users
DROP INDEX unique_email;
Q30
Multiple Choice

Choose the correct ALTER TABLE statement to modify multiple columns in a table.

SQL Code
ALTER TABLE employees
MODIFY COLUMN last_name VARCHAR(100),
MODIFY COLUMN first_name VARCHAR(100);