Repaso
EspaƱol

Which is true about a PRIMARY KEY vs a UNIQUE constraint?

Options

  1. Both of them allow multiple NULLs in the constrained column
  2. One primary key per table (NOT NULL); many UNIQUE constraints (Correct option)
  3. A UNIQUE constraint never creates an index in the table
  4. Primary keys must always be integers, never text or UUIDs

Answer

A table has one primary key (NOT NULL, unique); it can have many UNIQUE constraints, which usually allow NULLs

Why

The primary key is THE identifier of each row: unique and never NULL, and a table has only one.

A UNIQUE constraint just forbids duplicate values in a column (like email). You can have several, and they usually allow NULL.

Both create an index automatically. Primary keys can be integers, UUIDs or other types.

Remember

One primary key per table; many UNIQUE constraints allowed.

Key terms

Practice this question in Repaso