MySQL Database Quiz Questions

Course Name:MySQL
Chapter Name:Chapter 5 - DDL (Data Definition Language)
Lesson Content Link:UNIQUE Constraint
Current Quiz Count:30
Progress
0%
Q1
True / False

In MySQL, a UNIQUE constraint ensures that all values in a column are different.

Q2
True / False

MySQL allows NULL values in a column with a UNIQUE constraint.

Q3
True / False

You cannot add a UNIQUE constraint to an existing table in MySQL.

Q4
True / False

In MySQL, a table can have only one UNIQUE constraint.

Q5
True / False

Dropping a UNIQUE constraint in MySQL requires the use of the DROP CONSTRAINT clause.

Q6
True / False

In MySQL, UNIQUE constraints can be defined on multiple columns to ensure that the combination of column values is unique.

Q7
True / False

MySQL's UNIQUE constraint can be temporarily disabled and re-enabled for maintenance purposes.

Q8
True / False

Adding a UNIQUE constraint on a column with existing duplicate values will fail in MySQL.

Q9
True / False

In MySQL, a UNIQUE constraint always creates a unique index automatically.

Q10
True / False

In MySQL certification exams, knowledge of using the UNIQUE constraint in conjunction with foreign keys is essential.

Q11
Single Choice

Which of the following best describes the UNIQUE constraint in MySQL?

Q12
Single Choice

How do you add a UNIQUE constraint to an existing column in MySQL?

Q13
Single Choice

What happens if you try to insert a duplicate value into a column with a UNIQUE constraint in MySQL?

Q14
Single Choice

How can you define a UNIQUE constraint on multiple columns in a MySQL table?

Q15
Single Choice

Which SQL keyword is used to remove a UNIQUE constraint in MySQL?

Q16
Single Choice

Can a column with a UNIQUE constraint in MySQL contain NULL values?

Q17
Single Choice

How do you create a UNIQUE constraint on an existing table for a combination of columns in MySQL?

Q18
Single Choice

What is the maximum number of UNIQUE constraints you can have on a MySQL table?

Q19
Single Choice

Which of the following is true about the UNIQUE constraint and primary keys in MySQL?

Q20
Single Choice

Which of the following MySQL statements correctly removes a UNIQUE constraint named unique_key from the table employees?

Q21
Multiple Choice

Identify the correct SQL statement to create a table with a UNIQUE constraint on a single column.

SQL Code
CREATE TABLE users (
 user_id INT PRIMARY KEY,
 email VARCHAR(100) UNIQUE
);
Q22
Multiple Choice

Choose the correct SQL statement to add a UNIQUE constraint to an existing column.

SQL Code
ALTER TABLE employees
ADD CONSTRAINT unique_ssn UNIQUE(ssn);
Q23
Multiple Choice

Determine the correct SQL statement to create a table with a composite UNIQUE constraint.

SQL Code
CREATE TABLE orders (
 order_id INT,
 product_id INT,
 customer_id INT,
 UNIQUE (order_id, product_id)
);
Q24
Multiple Choice

Which SQL statement correctly drops a UNIQUE constraint from a table?

SQL Code
ALTER TABLE employees
DROP INDEX unique_email;
Q25
Multiple Choice

Select the correct SQL statement to create a table where a column has both NOT NULL and UNIQUE constraints.

SQL Code
CREATE TABLE products (
 product_id INT PRIMARY KEY,
 product_code VARCHAR(50) NOT NULL UNIQUE
);
Q26
Multiple Choice

Identify the correct SQL statement to enforce a UNIQUE constraint across multiple columns in an existing table.

SQL Code
ALTER TABLE customers
ADD CONSTRAINT unique_name_address UNIQUE (first_name, last_name, address);
Q27
Multiple Choice

Which SQL statement correctly creates a table with a UNIQUE constraint that allows for NULL values?

SQL Code
CREATE TABLE inventory (
 inventory_id INT PRIMARY KEY,
 serial_number VARCHAR(50) UNIQUE
);
Q28
Multiple Choice

Determine the correct SQL statement to add a UNIQUE constraint and ensure no existing duplicate values cause errors.

SQL Code
ALTER IGNORE TABLE employees
ADD UNIQUE (email);
Q29
Multiple Choice

Select the correct SQL statement to enforce a UNIQUE constraint on a column while creating an index for faster lookups.

SQL Code
CREATE UNIQUE INDEX idx_employee_ssn
ON employees (ssn);
Q30
Multiple Choice

Which SQL statement correctly enforces a UNIQUE constraint on a column in an existing table with existing data?

SQL Code
ALTER TABLE customers
ADD CONSTRAINT unique_phone_number UNIQUE (phone_number);