SQL Interview Questions
Top SQL Interview Questions
You Must Know
Jayasurya SM
Data Analyst
Swipe right
Basics (1)
Q1: What is SQL
SQL (Structured Query Language) is a standard language for storing,
managing, and retrieving data in relational databases.
Advanced Tip: SQL is declarative → you specify what you want, not
how. Query optimizers handle execution.
Q2: What are SQL command types (DDL, DML, DCL,
TCL)?
DDL (Data Definition Language): CREATE, ALTER, DROP – defines
structure.
DML (Data Manipulation Language): SELECT, INSERT, UPDATE,
DELETE – works with data.
DCL (Data Control Language): GRANT, REVOKE – controls
permissions.
TCL (Transaction Control Language): COMMIT, ROLLBACK,
SAVEPOINT – manages transactions.
Q3: SQL vs NoSQL?
SQL: Relational, structured, uses tables. Great for ACID
transactions.
NoSQL: Non-relational, schema-less, good for unstructured/large-
scale data (e.g., MongoDB).
Swipe right
Basics (2)
Q1: What is a Primary Key?
A column (or set of columns) that uniquely identifies each row.
Cannot be NULL.
Q2: What is a Foreign Key?
A column that references a primary key in another table to
maintain relationships.
Q3: Primary Key vs Unique Key?
Primary Key: Only one per table, auto-indexed, no NULL allowed.
Unique Key: Multiple allowed, ensures unique values but NULLs
are allowed.
Q4: What is a Composite Key?
A key made up of two or more columns that together uniquely
identify a row. Useful when no single column is unique by itself.
Q5: What is a Candidate Key?
A column (or set of columns) that can qualify as a Primary Key. A
table may have multiple candidate keys, but only one is chosen as
the Primary Key.
Swipe right