Unique Key
A unique key (UNIQUE constraint) ensures that no two rows in a table have the same value in a column or set of columns. It is used for data that must not repeat but is not the main identifier, such as an email address or a phone number.
Unlike a primary key, a table can have many unique keys, and a unique column usually allows NULL (most databases allow several NULLs, SQL Server allows one). The database creates an index for each unique key to check uniqueness quickly.
CREATE TABLE users (
id INT PRIMARY KEY,
email VARCHAR(255) UNIQUE,
phone VARCHAR(20),
CONSTRAINT uq_users_phone UNIQUE (phone)
);
