Complete the code to add a UNIQUE constraint on the email column.
CREATE TABLE users (id INT PRIMARY KEY, email VARCHAR(255) [1]);
The UNIQUE constraint ensures that all values in the email column are different.
Complete the code to add a UNIQUE constraint on the code column.
CREATE TABLE products (id INT PRIMARY KEY, code VARCHAR(50) [1]);
The UNIQUE constraint ensures that all values in the code column are different.
Complete the code to add a UNIQUE constraint to the username column after table creation.
ALTER TABLE users ADD CONSTRAINT [1] UNIQUE (username);You must name the UNIQUE constraint. 'unique_username' is a good descriptive name.
Fill both blanks to create a UNIQUE constraint on two columns: first_name and last_name.
ALTER TABLE employees ADD CONSTRAINT [1] [2] (first_name, last_name);
The constraint name is 'unique_fullname' and the type is UNIQUE to ensure the combination of first_name and last_name is unique.
Fill all three blanks to create a table with a UNIQUE constraint on the email column and a PRIMARY KEY on id.
CREATE TABLE customers ([1] INT [2], email VARCHAR(255) [3]);
The id column is defined as PRIMARY KEY, and the email column has a UNIQUE constraint to prevent duplicate emails.