SQL Interview Questions and Answers for Freshers 2026

SQL turns up in almost every technical interview for software, data, and backend roles. The good news is interviewers test the same core concepts — JOINs, GROUP BY, subqueries, indexes. Know these well and you'll handle most SQL rounds without much trouble.
SQL Command Categories
DDL
CREATE, ALTER, DROP, TRUNCATE
DML
SELECT, INSERT, UPDATE, DELETE
DCL
GRANT, REVOKE
TCL
COMMIT, ROLLBACK, SAVEPOINT
Common SQL Interview Questions
Q1
What is the difference between WHERE and HAVING?
WHERE filters rows before grouping is applied. HAVING filters groups after GROUP BY. You cannot use aggregate functions (COUNT, SUM, AVG) in WHERE, but you can in HAVING.
Q2
What are the types of JOINs in SQL?
INNER JOIN: returns only matching rows from both tables. LEFT JOIN: returns all rows from the left table and matching rows from the right. RIGHT JOIN: returns all rows from the right table and matching rows from the left. FULL OUTER JOIN: returns all rows from both tables, with NULLs where there is no match.
Q3
What is the difference between DELETE, TRUNCATE, and DROP?
DELETE removes specific rows (can use WHERE, can be rolled back). TRUNCATE removes all rows from a table quickly (cannot use WHERE, cannot be rolled back by default). DROP removes the entire table structure and data permanently.
Q4
What is a PRIMARY KEY?
A PRIMARY KEY uniquely identifies each row in a table. It cannot contain NULL values and must be unique. A table can have only one primary key, but it can consist of multiple columns (composite key).
Q5
What is a FOREIGN KEY?
A FOREIGN KEY is a column that references the PRIMARY KEY of another table, establishing a relationship between the two tables. It enforces referential integrity — you cannot insert a value that does not exist in the referenced table.
Q6
What is normalization? Explain 1NF, 2NF, and 3NF.
Normalization reduces data redundancy. 1NF: each column contains atomic (indivisible) values, no repeating groups. 2NF: satisfies 1NF and every non-key attribute is fully dependent on the entire primary key. 3NF: satisfies 2NF and no transitive dependencies (non-key column depending on another non-key column).
Q7
What is a subquery?
A subquery is a query nested inside another query. It can appear in the SELECT, FROM, or WHERE clause. A correlated subquery references columns from the outer query and runs once for each row.
Q8
What is the difference between UNION and UNION ALL?
UNION combines results from two SELECT statements and removes duplicate rows. UNION ALL keeps all rows including duplicates. UNION ALL is faster because it skips the deduplication step.
Q9
What is an index and when should you use it?
An index is a database object that speeds up SELECT queries on a column. It works like a book index. Use indexes on columns frequently used in WHERE, JOIN, and ORDER BY clauses. Avoid over-indexing — indexes slow down INSERT, UPDATE, and DELETE operations.
Q10
What is a stored procedure?
A stored procedure is a precompiled set of SQL statements saved in the database. It can accept input parameters, return results, and be reused. Benefits include better performance (compiled once), code reuse, and security (users can execute procedures without direct table access).
Tips for SQL Interviews
- Practice writing queries by hand — not just reading them
- Understand JOINs deeply — they are asked in almost every interview
- Know the difference between WHERE and HAVING — a classic question
- Practice aggregate functions: COUNT, SUM, AVG, MIN, MAX with GROUP BY
- Be ready to write a query on the spot — interviewers often test with live problems
Final Thoughts
SQL is a foundational skill for almost every technical role. Master the core concepts, practice writing real queries, and be ready to explain your reasoning during interviews. Strengthen your overall interview performance with AI-powered mock interviews at Roundexa.com.
Read Next
Java Interview Questions and Answers for Freshers 2026
Java interviews follow patterns. This guide covers the questions that come up most — OOP, Collections, Exception Handling, multithreading — with answers that are easy to understand and explain.
TCS Interview Questions and Answers for Freshers 2026
Getting ready for a TCS interview? Here's what actually gets asked across every round — technical, managerial, and HR — with clear answers and tips from candidates who've been through it.