UNIQUE and PRIMARY KEY

mysql, sql

Solution

Nope.

PRIMARY KEYs must be UNIQUE, but UNIQUE keys need not be primary. You can have multiple UNIQUE keys in a table.

The key difference is that PRIMARY keys can not have NULL values, as they must uniquely identify a row. UNIQUE keys may be NULL, and multiple NULL values are permitted (unless you're using an uncommon table engine like BDB).

Problem

Is declaring an attribute of a table as UNIQUE equivalent to declaring it as PRIMARY KEY?

Original source