SQL developer interview questions and answers
SQL comes up in almost every technical interview, and database roles go much deeper. These are the questions asked most, from basics to performance, with what each one checks.
What to revise before the interview
- Joins, GROUP BY, subqueries and CTEs
- Normalisation: 1NF, 2NF, 3NF
- Primary, foreign and unique keys
- Indexes: how they work, when they hurt
- Transactions, ACID and isolation levels
- Stored procedures, views and triggers
- Reading execution plans
- Deleting duplicates, finding gaps, top N per group
1.What is normalisation? Explain up to 3NF.
- What they're checking
- Database design fundamentals.
- How to answer
- Organising tables to reduce duplication. 1NF: atomic values, no repeating groups. 2NF: no partial dependency on part of a composite key. 3NF: no dependency of non-key columns on other non-key columns.
2.How does an index speed up a query, and when can it slow things down?
- What they're checking
- Performance understanding.
- How to answer
- An index (usually a B-tree) lets the database find rows without scanning the whole table. It slows inserts and updates, uses space, and won't help low-selectivity columns or functions applied to the column.
3.What does ACID mean?
- What they're checking
- Transaction basics.
- How to answer
- Atomicity (all or nothing), Consistency (rules hold), Isolation (concurrent transactions don't interfere), Durability (committed data survives crashes). Example: a bank transfer debits and credits together or not at all.
4.DELETE vs TRUNCATE vs DROP?
- What they're checking
- Common fresher question.
- How to answer
- DELETE removes chosen rows and can be rolled back in a transaction; TRUNCATE removes all rows quickly; DROP removes the table itself. Behaviour details vary slightly by database.
5.How do you remove duplicate rows but keep one?
- What they're checking
- A practical query problem.
- How to answer
- Use ROW_NUMBER() OVER (PARTITION BY the duplicate columns ORDER BY id) and delete rows where the number is greater than 1.
6.Find the top 3 earners in each department.
- What they're checking
- Window functions in action.
- How to answer
- DENSE_RANK() OVER (PARTITION BY department ORDER BY salary DESC) in a CTE, then filter rank <= 3. Mention RANK vs DENSE_RANK for ties.
7.A query is slow. How do you fix it?
- What they're checking
- Real troubleshooting.
- How to answer
- Read the execution plan, look for full scans and bad joins, add or adjust indexes, select only needed columns, avoid functions on indexed columns in WHERE, and check statistics are up to date.
8.What are isolation levels?
- What they're checking
- Deeper concurrency knowledge for experienced roles.
- How to answer
- Read uncommitted, read committed, repeatable read and serializable - each prevents more anomalies (dirty, non-repeatable and phantom reads) at a cost to concurrency.
9.View vs stored procedure?
- What they're checking
- Database object knowledge.
- How to answer
- A view is a saved query you select from; a stored procedure is saved logic that can take parameters, run several statements and modify data.
10.What is the difference between UNION and UNION ALL?
- What they're checking
- Basics and performance awareness.
- How to answer
- UNION removes duplicates (extra work); UNION ALL keeps all rows and is faster. Use UNION ALL unless you need de-duplication.
On a live call, Cuelyte AI hears questions like these and has an answer ready in about a second, built from your resume and notes. Coding interviews: how Cuelyte AI helps
Frequently asked questions
What SQL topics are asked most in interviews?
Joins, GROUP BY with HAVING, subqueries, window functions, normalisation, indexes and classic queries such as the Nth highest salary or deleting duplicates.
Which database should I practise on?
Any - MySQL, PostgreSQL or SQL Server. Standard SQL is mostly the same; just know the small differences in the one the job uses.
Are DBMS theory questions asked to freshers?
Yes, especially in campus drives: keys, normalisation, ACID, transactions and the difference between DBMS and RDBMS.
Company interview guides for this role
- Oracle interview questions
- TCS interview questions
- Infosys interview questions
- HDFC Bank interview questions
- Wells Fargo interview questions
Related roles and topics
- Data analyst interview questions
- Java developer interview questions
- .NET developer interview questions
- Data scientist interview questions
- HR interview questions
- Behavioural interview questions
- Coding interview questions
- System design interview questions
- Interview questions for freshers
- Sales interview questions
- All roles →
Practise these questions for your next interview
Add your resume to Cuelyte AI, type a question and get a clear answer in your own words - in English, Hindi or Hinglish. Free to start.