thinQmaster Virtual testing partner Adaptive practice exams that find your weak spots and drill them. Every answer explained. From $69
Enroll

thinQmaster

Find your exam

Five questions free, before you decide.

Step 1 · choose a vendor

In one of our camps? Your practice exams come with the tuition — they are on your study page already.

Data & Analytics · Foundational

Unique Constraint

A constraint that prevents duplicate values in a column or column combination.

Definition

UNIQUE enforces uniqueness the way a primary key does, but a table may have many unique constraints. Most systems allow NULLs in unique columns; SQL Server allows only one NULL, while PostgreSQL and Oracle allow several. Databases usually back the constraint with a unique index.

Example

ALTER TABLE Users ADD CONSTRAINT UQ_Email UNIQUE (Email);

Exam tip

Primary key = unique + not null and only one per table; unique constraint = unique, may allow NULL, and many per table.

Related terms