PrepZone Logo
PrepZone
Back to Database

Database · Easy

What is the difference between a PRIMARY KEY and a UNIQUE constraint?

DatabaseFundamentalsFresher

Answer preview

Both enforce uniqueness and both create a unique index, but a PRIMARY KEY is the table's single chosen row identifier and implicitly NOT NULL, while a UNIQUE constraint is an alternate key that allows NULLs and can be declared many times per table.…