SQL Developer Interview Questions

Udhay Chezhiyan Avatar

SQL Developer interview questions focus on database concepts, SQL queries, optimization, and data manipulation skills. Here are 25 commonly asked questions with answers to help you prepare effectively.

Q1. What is SQL?

SQL (Structured Query Language) is a standard programming language used to manage and manipulate relational databases.

Q2. What are the different types of SQL commands?

SQL commands are categorized into DDL (Data Definition Language), DML (Data Manipulation Language), DCL (Data Control Language), and TCL (Transaction Control Language).

Q3. What is the difference between DELETE and TRUNCATE?

DELETE removes rows one by one and can be rolled back, while TRUNCATE removes all rows quickly without logging individual row deletions and cannot be rolled back.

Q4. What is a primary key?

A primary key is a column or set of columns that uniquely identifies each row in a table and does not allow NULL values.

Q5. What are joins? Name different types.

Joins combine rows from two or more tables based on related columns. Types include INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL OUTER JOIN, CROSS JOIN.

Q6. What is normalization?

Normalization is the process of organizing data to reduce redundancy and improve data integrity by dividing tables into smaller related tables.

Q7. What are indexes? Why are they used?

Indexes are database objects that speed up the retrieval of rows by using pointers. They improve query performance but slow down data modification operations.

Q8. What is a foreign key?

A foreign key is a column or set of columns in one table that refers to the primary key in another table to enforce referential integrity.

Q9. What is the difference between WHERE and HAVING clauses?

WHERE filters rows before grouping, while HAVING filters groups after aggregation.

Q10. What is a view in SQL?

A view is a virtual table based on the result set of a SELECT query, which does not store data physically but provides a way to simplify complex queries.

Q11. What are stored procedures?

Stored procedures are precompiled SQL code saved in the database that can be executed to perform specific tasks.

Q12. What is a transaction in SQL?

A transaction is a sequence of SQL operations performed as a single unit of work, which is either fully completed or fully rolled back.

Q13. What are ACID properties?

ACID stands for Atomicity, Consistency, Isolation, Durability — key properties that ensure reliable transaction processing.

Q14. How do you optimize a SQL query?

By using indexes, avoiding unnecessary columns in SELECT, minimizing subqueries, using JOINs effectively, and analyzing execution plans.

Q15. What is a cluster index?

A cluster index determines the physical order of data in a table and can improve range query performance.

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

UNION removes duplicate rows between the queries, while UNION ALL includes all rows including duplicates.

Q17. What is the use of the EXISTS clause?

EXISTS checks for the existence of rows returned by a subquery and returns TRUE if at least one row exists.

Q18. What is a self-join?

A self-join is a join where a table is joined with itself to compare rows within the same table.

Q19. What are triggers?

Triggers are database procedures automatically executed in response to certain events on a table such as INSERT, UPDATE, or DELETE.

Q20. How do you handle NULL values in SQL?

Using IS NULL or IS NOT NULL operators, and functions like COALESCE and NVL to manage NULL values.

Q21. What is the difference between CHAR and VARCHAR?

CHAR is fixed-length, storing a fixed number of characters, while VARCHAR is variable-length, storing only the actual characters plus overhead.

Q22. What is the difference between an inner join and a left join?

Inner join returns rows with matching values in both tables; left join returns all rows from the left table plus matched rows from the right table.

Q23. What is a composite key?

A composite key is a primary key made up of two or more columns to uniquely identify a row.

Q24. What is the difference between a function and a stored procedure?

Functions return a single value and can be used in SQL statements, while stored procedures perform operations and may not return a value.

Q25. What are the different types of backups in SQL Server?

Full backup, differential backup, and transaction log backup.


About the Author

Udhay Chezhiyan Avatar

Leave a Reply

Your email address will not be published. Required fields are marked *

More Articles & Posts