0% found this document useful (0 votes)
4 views5 pages

Top 50 SQL Interview Questions

This document provides a comprehensive list of the top 50 SQL interview questions and concepts, including explanations of key topics such as data types, constraints, joins, and normalization. It serves as a resource for interview preparation and quick revision. The content covers essential SQL knowledge necessary for understanding database management and operations.

Uploaded by

ojasvikandpal669
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views5 pages

Top 50 SQL Interview Questions

This document provides a comprehensive list of the top 50 SQL interview questions and concepts, including explanations of key topics such as data types, constraints, joins, and normalization. It serves as a resource for interview preparation and quick revision. The content covers essential SQL knowledge necessary for understanding database management and operations.

Uploaded by

ojasvikandpal669
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Top 50 SQL Interview Questions & Concepts

This PDF contains important SQL and DBMS interview questions with concise explanations for interview preparation
and quick revision.

1. Difference between CHAR and VARCHAR2

CHAR stores fixed-length data while VARCHAR2 stores variable-length data.

2. What is a View in SQL?

A view is a virtual table created using a SELECT query.

3. UNIQUE Constraint

Ensures all values in a column are distinct.

4. Composite Primary Key

Uses multiple columns together to uniquely identify rows.

5. WHERE vs HAVING

WHERE filters rows before grouping. HAVING filters grouped data.

6. SQL Joins

INNER, LEFT, RIGHT and FULL joins combine tables differently.

7. PRIMARY KEY vs UNIQUE

PRIMARY KEY is UNIQUE + NOT NULL. UNIQUE allows multiple constraints.

8. What is a CTE?

A Common Table Expression is a temporary named result set.

9. Normalization

Reduces redundancy using 1NF, 2NF, 3NF and BCNF.

10. UNION vs UNION ALL


UNION removes duplicates while UNION ALL keeps them.

11. Clustered vs Non-Clustered Index

Clustered indexes store rows physically in order.

12. Pattern Matching

LIKE uses % and _ wildcards.

13. Running Total

Use SUM() OVER() window function.

14. Correlated Subquery

Subquery dependent on outer query rows.

15. EXISTS vs IN

EXISTS checks row existence. IN compares values.

16. Anti-Join

Returns rows without matching rows in another table.

17. RANK vs DENSE_RANK vs ROW_NUMBER

Different ranking functions for ordered results.

18. LAG and LEAD

Access previous or next row values.

19. CROSS JOIN vs INNER JOIN

CROSS JOIN creates all combinations.

20. Foreign Keys

Maintain referential integrity between tables.

21. Set Operations


UNION, INTERSECT and EXCEPT combine query results.

22. Query Optimization

Use indexes, EXPLAIN and optimized joins.

23. What is a Query?

A SQL statement to retrieve or manipulate data.

24. What is a Subquery?

A query nested inside another query.

25. Database Partitioning

Splits large tables into smaller partitions.

26. Preventing SQL Injection

Use parameterized queries and validation.

27. Types of SQL Commands

DDL, DML, DCL and TCL.

28. DEFAULT Constraint

Assigns default values automatically.

29. Denormalization

Combines tables for faster reads.

30. SQL Operators

Arithmetic, logical, comparison and set operators.

31. Types of Joins

INNER, LEFT, RIGHT, FULL, CROSS and SELF JOIN.

32. GROUP BY Clause


Groups rows for aggregate calculations.

33. Aggregate Functions

COUNT, SUM, AVG, MIN and MAX.

34. Indexes

Improve query performance.

35. DELETE vs TRUNCATE

DELETE removes rows individually. TRUNCATE removes all rows quickly.

36. SQL vs NoSQL

SQL uses structured schema. NoSQL is flexible.

37. Constraints

NOT NULL, UNIQUE, PRIMARY KEY, FOREIGN KEY and CHECK.

38. Cursor

Processes result rows one at a time.

39. Trigger

Automatically runs on INSERT, UPDATE or DELETE.

40. SELECT Statement

Retrieves data from tables.

41. ORDER BY Clause

Sorts query results.

42. What is a Table?

Rows and columns storing related data.

43. NULL Values


Represent missing or unknown data.

44. Stored Procedure

Precompiled SQL logic stored in DB.

45. DDL vs DML

DDL changes structure. DML changes data.

46. ALTER Command

Modifies table structure.

47. Data Integrity

Ensures consistency and reliability of data.

48. ACID Properties

Atomicity, Consistency, Isolation and Durability.

49. Transactions

Group of SQL operations executed together.

50. Referential Integrity

Maintains valid relationships between tables.

You might also like