The UNIQUE constraint ensures that all values in a column are distinct, that is, the column cannot contain two identical instances of any value. Attempting to insert a duplicate value into a UNIQUE column will violate the UNIQUE constraint and result in an error.
The UNIQUE and PRIMARY KEY constraints both provide a guarantee for uniqueness for a column or set of columns.
Note that a PRIMARY KEY constraint automatically includes a UNIQUE constraint.
CREATE TABLE users
(user_id integer Unique,
Last_Name varchar (30),
Related Code Snippets:
- Unique Constraint - A unique constraint is a single field or combination of fields that uniquely d...