SQL Questions

 SQL Interview Questions Only (Organized for Preparation)


Beginner Level (20 Questions)

  1. What is SQL?

  2. What are the different types of SQL commands?

  3. What is the difference between DDL and DML?

  4. What is a Primary Key?

  5. What is a Foreign Key?

  6. What is a Unique Key?

  7. What is the difference between WHERE and HAVING clause?

  8. What is a NULL value in SQL?

  9. What is a constraint?

  10. What are indexes in SQL?

  11. How to fetch unique records from a table?

  12. What is the difference between DELETE and TRUNCATE?

  13. What is the purpose of the GROUP BY clause?

  14. What is a View in SQL?

  15. What is normalization?

  16. What are the types of normalization?

  17. What is the use of the ORDER BY clause?

  18. What are aggregate functions in SQL?

  19. What is a default constraint?

  20. What are aliases in SQL?


Intermediate Level (20 Questions)

  1. What are the types of JOINs in SQL?

  2. Explain INNER JOIN with an example.

  3. Explain LEFT JOIN with an example.

  4. Explain RIGHT JOIN with an example.

  5. Explain FULL JOIN with an example.

  6. What is a subquery?

  7. What is a correlated subquery?

  8. What is the difference between UNION and UNION ALL?

  9. What are stored procedures?

  10. What are functions in SQL?

  11. What is a trigger in SQL?

  12. What are transactions in SQL?

  13. Explain COMMIT and ROLLBACK.

  14. What is a savepoint in transactions?

  15. What are window functions in SQL?

  16. What is the purpose of the RANK() function?

  17. How do you handle duplicate data in SQL?

  18. What is the EXISTS operator?

  19. What is a materialized view?

  20. Explain the concept of self-join.


Advanced Level (20 Questions)

  1. What is query optimization?

  2. What are common techniques for SQL query optimization?

  3. What is a clustered index vs non-clustered index?

  4. How does indexing improve query performance?

  5. What are ACID properties in SQL?

  6. What are Isolation levels in SQL transactions?

  7. What is deadlock in SQL and how to prevent it?

  8. How to perform database backup and restore?

  9. What is database sharding?

  10. What is partitioning in SQL?

  11. How to find the second highest salary using SQL?

  12. What is the COALESCE() function?

  13. What is the CASE WHEN statement?

  14. What is recursive query? (CTE)

  15. What is a CROSS JOIN?

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

  17. What is the difference between CHAR and VARCHAR?

  18. How to check database performance in SQL?

  19. What is the EXPLAIN plan in MySQL?

  20. How do you handle large databases with millions of rows?


Key Topics for SQL

  • SQL Basics (DDL, DML, DCL, TCL, DQL)

  • Tables and Keys (Primary, Foreign, Composite)

  • Basic Queries (SELECT, WHERE, ORDER BY, GROUP BY, HAVING)

  • Joins (INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL JOIN)

  • Subqueries

  • Constraints (NOT NULL, UNIQUE, CHECK, DEFAULT)

  • Normalization (1NF, 2NF, 3NF)

  • Indexes (Clustered, Non-Clustered)

  • Transactions (COMMIT, ROLLBACK, SAVEPOINT)

  • Views

  • Stored Procedures, Functions, Triggers

  • Optimization Techniques

  • Window Functions (ROW_NUMBER, RANK, DENSE_RANK)

  • Backup and Restore

  • Functions (COALESCE, CASE WHEN)


Bonus Tips for SQL

  • Practice SQL queries daily on LeetCode or W3Schools SQL editor.

  • Create a mini project like "Library Management System."

  • Write subqueries and joins regularly.

  • Learn indexing and optimization tricks.

  • Revise important definitions and functions.

  • Explain queries out loud to yourself for practice.

  • Understand Execution Plan (EXPLAIN keyword).


End of SQL Questions PDF

Comments

Popular posts from this blog

PHP INTERVIEW QUESTIONS

PHP Intermediate Questions Interview Preparation

PHP Interview Questions (Beginner Level) – Short Answers