Q1
True / FalseIn MySQL, a UNIQUE constraint ensures that all values in a column are different.
The UNIQUE constraint in MySQL ensures that all values in a specified column are unique, meaning no two rows can have the same value in that column.
Q2
True / FalseMySQL allows NULL values in a column with a UNIQUE constraint.
In MySQL, a column with a UNIQUE constraint can have multiple NULL values, because NULL is considered different from any other NULL value.
Q3
True / FalseYou cannot add a UNIQUE constraint to an existing table in MySQL.
You can add a UNIQUE constraint to an existing table in MySQL using the ALTER TABLE statement.
Q4
True / FalseIn MySQL, a table can have only one UNIQUE constraint.
MySQL allows multiple UNIQUE constraints in a single table, each applying to different columns or sets of columns.
Q5
True / FalseDropping a UNIQUE constraint in MySQL requires the use of the DROP CONSTRAINT clause.
In MySQL, the correct syntax to drop a UNIQUE constraint involves using the DROP INDEX statement because UNIQUE constraints are implemented using unique indexes.
Q6
True / FalseIn MySQL, UNIQUE constraints can be defined on multiple columns to ensure that the combination of column values is unique.
MySQL allows UNIQUE constraints on multiple columns, ensuring that the combined values of the columns are unique across the table.
Q7
True / FalseMySQL's UNIQUE constraint can be temporarily disabled and re-enabled for maintenance purposes.
MySQL does not support temporarily disabling and re-enabling UNIQUE constraints. Constraints must be dropped and re-created if modifications are needed.
Q8
True / FalseAdding a UNIQUE constraint on a column with existing duplicate values will fail in MySQL.
If you try to add a UNIQUE constraint to a column with existing duplicate values, MySQL will reject the operation because it violates the uniqueness requirement.
Q9
True / FalseIn MySQL, a UNIQUE constraint always creates a unique index automatically.
MySQL enforces the UNIQUE constraint by automatically creating a unique index on the specified column(s).
Q10
True / FalseIn MySQL certification exams, knowledge of using the UNIQUE constraint in conjunction with foreign keys is essential.
Understanding how to use the UNIQUE constraint along with foreign keys is an important aspect of MySQL database design and is often tested in certification exams.
Q23
Multiple ChoiceDetermine 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)
);
A composite UNIQUE constraint ensures that the combination of values in order_id and product_id columns is unique across the table.
Q26
Multiple ChoiceIdentify 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);
This SQL statement adds a composite UNIQUE constraint across the first_name, last_name, and address columns, ensuring no duplicate entries for these combinations.