SQL DatabaseLesson 54Free preview
SQL Unique
This lesson is part of SQL · All levels
Summary
The UNIQUE constraint ensures that all values in the column are different from each other, but still may contain NULL. Suitable for user email or double-digit identification numbers. This constraint can be applied per column or as a combination to several columns.
Key points
- UNIQUE guarantees no two rows with the same value on the column.
- The value of NULL remains permissible and in MySQL can be more than one NULL.
- It can be written in the UNIQUE column or through the ADD CONSTRAINT... UNIQUE column.
- A unique constraint automatically creates an index to speed up the search.
- The primary key is stricter than the unique because it does not allow.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.