← All Guides
🔵15 QUESTIONS • BEGINNER TO ADVANCED

Top 50 SQL Interview Questions (2026)

Most asked SQL interview questions covering JOINs, indexes, normalization, transactions, and query optimization.

Interview Questions & Answers

1

What is SQL?

SQL (Structured Query Language) is a standard language for managing and manipulating relational databases. It is used to create, read, update, and delete data in databases like MySQL, PostgreSQL, and SQL Server.

2

What is the difference between DELETE, DROP, and TRUNCATE?

DELETE removes specific rows and can be rolled back. TRUNCATE removes all rows, cannot be rolled back, and is faster. DROP removes the entire table structure including data.

3

What are the different types of JOINs?

INNER JOIN returns matching rows from both tables. LEFT JOIN returns all rows from left table and matching from right. RIGHT JOIN is opposite. FULL OUTER JOIN returns all rows when there is a match in either table.

4

What is a PRIMARY KEY?

A PRIMARY KEY is a column or set of columns that uniquely identifies each row in a table. It cannot contain NULL values and must be unique. Each table can have only one primary key.

5

What is a FOREIGN KEY?

A FOREIGN KEY is a column that creates a link between two tables. It references the PRIMARY KEY of another table, enforcing referential integrity.

6

What is normalization?

Normalization is the process of organizing a database to reduce redundancy and improve data integrity. Common forms are 1NF, 2NF, 3NF, and BCNF. Each form has specific rules to eliminate different types of anomalies.

7

What is an INDEX?

An index is a database structure that improves the speed of data retrieval. It creates a separate data structure pointing to rows in the original table. Indexes speed up SELECT queries but slow down INSERT/UPDATE/DELETE.

8

What is the difference between WHERE and HAVING?

WHERE filters rows before grouping and cannot use aggregate functions. HAVING filters groups after GROUP BY and can use aggregate functions like COUNT, SUM, AVG.

9

What is a subquery?

A subquery is a query nested inside another query. It can be used in SELECT, FROM, and WHERE clauses. A correlated subquery references columns from the outer query and executes once per row.

10

What are aggregate functions?

Aggregate functions perform calculations on a set of rows: COUNT() counts rows, SUM() adds values, AVG() calculates average, MAX() finds maximum, MIN() finds minimum.

11

What is a VIEW?

A VIEW is a virtual table based on the result of a SELECT statement. It does not store data itself. Views simplify complex queries, provide security by restricting column access, and present data in a specific format.

12

What is a TRANSACTION?

A transaction is a sequence of SQL operations executed as a single unit. It follows ACID properties: Atomicity, Consistency, Isolation, Durability. Use BEGIN, COMMIT, and ROLLBACK to control transactions.

13

What are ACID properties?

Atomicity: all operations succeed or all fail. Consistency: database remains in valid state. Isolation: concurrent transactions do not affect each other. Durability: committed transactions persist even after system failure.

14

What is the difference between UNION and UNION ALL?

UNION combines results of two SELECT statements and removes duplicates. UNION ALL combines results but keeps all duplicates, making it faster than UNION.

15

What is a stored procedure?

A stored procedure is a precompiled collection of SQL statements stored in the database. It improves performance, reduces network traffic, and allows code reuse. Can accept parameters and return values.

🔒

Want All 60 SQL Questions?

Sign up free to access complete notes — DSA, System Design, HR and more.

🚀 Access Full Notes Free →

Ready for your interview?

Build a professional resume to complement your preparation.

Build Free Resume →