beginner
Primary Key Constraint
5 min readLast updated: 2026-07-23
Overview
A Primary Key uniquely identifies each row in a table. It implicitly enforces both NOT NULL and UNIQUE constraints.
Learning Objectives
- Enforce entity integrity using
PRIMARY KEY. - Distinguish simple Primary Keys from Composite Primary Keys.
Code Examples
SQL
sql
CREATE TABLE employees (
emp_id INT PRIMARY KEY,
name VARCHAR(100) NOT NULL
);
Summary
Primary Keys guarantee unique row identification and prevent duplicate or null key entries.