Databases · Junior · Question 6 of 75
What is the difference between UNIQUE and PRIMARY KEY?
- 1
UNIQUEworks only on text columns - 2There is no difference
- ✓Correct answer: A table has one primary key, which can't be NULL; it can have many
UNIQUEconstraints, and in PostgreSQL they allow NULLs
Explanation
By default PostgreSQL treats NULLs as distinct, so a UNIQUE column can contain several NULLs. UNIQUE NULLS NOT DISTINCT changes that.