DEV Community

Shaique Hossain
Shaique Hossain

Posted on

UNIQUE KEY in SQL

A UNIQUE key in SQL is a constraint that ensures all values in a column or a combination of columns are unique across the table. This means no two rows can have the same value(s) in the specified column(s). Unlike the primary key, which must be unique and non-null, a table can have multiple UNIQUE keys, and they allow NULL values (although only one NULL per column if the UNIQUE constraint is applied). UNIQUE keys help maintain data integrity by preventing duplicate entries and can be defined during table creation or added later using the ALTER TABLE statement.

Top comments (0)