Home›Learn›SQL›UNIQUE Constraint
SQL Master CourseBeginner Friendly

UNIQUE Constraint

Learn how UNIQUE prevents duplicate values in a column or column combination.

📘 Chapter 39 / 51⏱️ 8–10 Min Read🎯 Beginner Friendly
Course Progress76%

Course Progress

76%

39 / 51 chapters

📖

Theory

Understand the concept step by step

The UNIQUE constraint ensures that values in the constrained column or column combination are unique. It is commonly used for values such as email addresses or usernames.
💻

Example

See how the concept works in SQL

SQL
CREATE TABLE users (
  id INT PRIMARY KEY,
  email VARCHAR(150) UNIQUE
);
📤

Output

Understand what the query produces

Each stored email value must satisfy the UNIQUE constraint.

📝

Practice

Test your understanding

Create a users table where username values must be unique.

❓

MCQs

Check your SQL knowledge

What is the main concept covered in UNIQUE Constraint?

A.Prevents duplicate constrained values
B.Deletes duplicates automatically
C.Sorts unique values
D.Creates a foreign key
💼

Interview Questions

Prepare for SQL interviews

1

Interview Question

What does UNIQUE do?

2

Interview Question

Can a table have multiple UNIQUE constraints?

3

Interview Question

How is UNIQUE different from PRIMARY KEY?