UNIQUE
UNIQUE constraint is used for the uniqueness of the value for the column in the table. UNIQUE constraint can have multiple in a table.
UNIQUE constraint is used for the uniqueness of the value for the column in the table. UNIQUE constraint can have multiple in a table.
Example
Following is the example to apply UNIQUE Constraint
on single column in CREATE TABLE
CREATE TABLE Employee
(
Id int
NOT NULL UNIQUE,
Name varchar(255) NOT NULL,
Address varchar(255),
Age int,
)
)
Following is the example to apply UNIQUE Constraint
on multiple column in CREATE TABLE
CREATE TABLE Employee
(
Id int
NOT NULL UNIQUE,
MobileNO int NULL UNIQUE,
Name varchar(255) NOT NULL,
Address varchar(255),
Age int,
)
Following is the example to apply UNIQUE Constraint on ALTER TABLE
)
Following is the example to apply UNIQUE Constraint on ALTER TABLE
ALTER TABLE Employee
ADD CONSTRAINT chk_ Id UNIQUE
Following is the example to DROP a UNIQUE Constraint
ALTER TABLE Employee
DROP CONSTRAINT chk_ Id
No comments:
Post a comment