📖
Theory
Understand the concept step by step
A primary key uniquely identifies each row in a table.
A primary key cannot contain NULL values and must be unique within the table.
A table has one primary key constraint, which can consist of one or multiple columns.
💻
Example
See how the concept works in SQL
SQL
CREATE TABLE users (
id INT PRIMARY KEY,
name VARCHAR(100)
);📤
Output
Understand what the query produces
The id column uniquely identifies each user.
📝
Practice
Test your understanding
Create a students table with id as the primary key.
❓
MCQs
Check your SQL knowledge
What is the main concept covered in Primary Key?
A.Uniquely identifies rows
B.Stores duplicate rows
C.Sorts a table
D.Creates a database
💼
Interview Questions
Prepare for SQL interviews
1
Interview Question
What is a primary key?
2
Interview Question
Can a primary key contain NULL?
3
Interview Question
Can a primary key contain duplicate values?