Example of UNIQUE constraint in SQL server-
CREATE TABLE Students (ID INT NOT NULL UNIQUE, FirstName VARCHAR(200),Fees INT);
Naming of UNIQUE constraint in SQL server during creation of table-
CREATE TABLE Students (ID INT NOT NULL, FirstName VARCHAR(200) NOT NULL, Fees INT , Age INT ,
CONSTRAINT unk UNIQUE (ID, FirstName)); –constraint named as unk
CHECK constraint creation on existing table-
ALTER TABLE Students
ADD UNIQUE (ID);
Naming of UNIQUE constraint in SQL server on existing table-
ALTER TABLE Students
ADD CONSTRAINT unk UNIQUE (ID,FirstName);
DROP a UNIQUE constraint-
ALTER TABLE Students
DROP CONSTRAINT unk;