Answer: The UNIQUE Constraint
Find a detailed explanation of how to use the UNIQUE constraint on columns of an existing table.
Solution
The solution is given below:
Press + to interact
/* Applying UNIQUE contraint on EmpName */ALTER TABLE Employees ADD UNIQUE (EmpName);/* Inserting a new record in the table */INSERT INTO Employees VALUES (5, 'Susan Lee', 5000);/* Retrieve the records in the table */SELECT * FROM Employees;
Explanation
The explanation of the solution code is given below:
Line 2: The
ALTER TABLE
query modifies a table.ADD
is used to add a constraint.UNIQUE
takes in a column name as a parameter and applies a unique constraint on that column.Line 5: The
INSERT INTO
statement is followed by the ...