SQL Keyword - UNIQUE

UNIQUE Keyword

The UNIQUE keyword or constraint is used to ensure that all values in a column are unique.

SQL UNIQUE ON CREATE TABLE

CREATE TABLE <TABLE_NAME> (
    <COLUMN_NAME> DATATYPE UNIQUE
);

Example

CREATE TABLE Employee (
    EMP_NO Integer UNIQUE
);

SQL UNIQUE ON ALTER TABLE

ALTER TABLE <TABLE_NAME>
ADD UNIQUE (<COLUMN_NAME>);

Example

ALTER TABLE Employee ADD UNIQUE(EMP_NO);

Summary

The UNIQUE constraint makes sure that each value in a column is distinct.