Unique Constraint
SQL Unique Constraint
A SQL Unique constraint verifies that no duplicate values are inserted in a specific columns that do not participate in a primary key.
A UNIQUE constraint can be referenced by a FOREIGN KEY constraint.
UNIQUE constraints allow for the value NULL.
When a unique constraint is created it automatically creates a unique index in the database.
Example
CREATE TABLE Certifications ( ID INT PRIMARY KEY, NAME VARCHAR(250) NOT NULL, DESCRIPTION VARCHAR(500), CONSTRAINT UK_IDCERT UNIQUE(NAME) );
Drop Unique Constraint
ALTER TABLE Certifications DROP CONSTRAINT UK_IDCERT;
Add Unique Constraint
ALTER TABLE Certifications ADD CONSTRAINT UK_IDCERT UNIQUE (NAME);