thinQmaster Virtual testing partner Adaptive practice exams that find your weak spots and drill them. Every answer explained. From $69
Enroll

thinQmaster

Find your exam

Five questions free, before you decide.

Step 1 · choose a vendor

In one of our camps? Your practice exams come with the tuition — they are on your study page already.

Data & Analytics · Foundational

Primary Key (PK)

A column or set of columns whose values uniquely identify each row in a table; it cannot contain NULLs.

Definition

The primary key is the candidate key chosen as a table's main identifier. It enforces entity integrity: values must be unique and non-null. Many RDBMSs, SQL Server among them, create a clustered index on the primary key by default.

Example

ALTER TABLE Orders ADD CONSTRAINT PK_Orders PRIMARY KEY (OrderID);

Exam tip

A table can have only one primary key, though that key may be composite (several columns).

Don't confuse it with

Related terms