What is the difference between a primary key and a unique key?

SQL keys and table design · Freshers

Model answer

Both enforce uniqueness. A table can have only one primary key and it cannot contain NULL, while it can have many unique constraints and (in most databases) they allow NULLs, though how many NULLs differs by database.

Learn this topic

Keys and Table Design: Why Data Is Split Into Tables in the course SQL for Beginners: Learn Databases Step by Step.

Sign in to add your own answer.

More questions