50 SQL Interview Questions PART-1

Deepshika

50 SQL Interview Questions

50 SQL Interview Questions, including both technical and non-technical questions, along with their answers PART-1

1. What is SQL?

– Answer: SQL (Structured Query Language) is a standard programming language specifically designed for managing and manipulating relational databases.

2. What are the different types of SQL statements?

– Answer: SQL statements can be classified into DDL (Data Definition Language), DML (Data Manipulation Language), DCL (Data Control Language), and TCL (Transaction Control Language).

3. What is a primary key?

– Answer: A primary key is a field (or combination of fields) in a table that uniquely identifies each row/record in that table.

4. What is a foreign key?

– Answer: A foreign key is a field (or collection of fields) in one table that uniquely identifies a row of another table or the same table. It establishes a link between the data in two tables.

5. What are joins? Explain different types of joins.

– Answer: A join is an SQL operation for combining records from two or more tables. Types of joins include INNER JOIN, LEFT JOIN (or LEFT OUTER JOIN), RIGHT JOIN (or RIGHT OUTER JOIN), and FULL JOIN (or FULL OUTER JOIN).

6. What is normalization?

– Answer: Normalization is the process of organizing data to reduce redundancy and improve data integrity. This typically involves dividing a database into two or more tables and defining relationships between them.

7. What is denormalization?

– Answer: Denormalization is the process of combining normalized tables into fewer tables to improve database read performance, sometimes at the expense of write performance and data integrity.

8. What is stored procedure?

– Answer: A stored procedure is a prepared SQL code that you can save and reuse. So, if you have an SQL query that you write frequently, you can save it as a stored procedure and then call it to execute it.

9. What is an index?

– Answer: An index is a database object that improves the speed of data retrieval operations on a table at the cost of additional storage and maintenance overhead.

10. What is a view in SQL?

– Answer: A view is a virtual table based on the result set of an SQL query. It contains rows and columns, just like a real table, but does not physically store the data.

11. What is a subquery?

– Answer: A subquery is an SQL query nested inside a larger query. It is used to return data that will be used in the main query as a condition to further restrict the data to be retrieved.

12. What are aggregate functions in SQL?

– Answer: Aggregate functions perform a calculation on a set of values and return a single value. Examples include COUNT, SUM, AVG (average), MIN (minimum), and MAX (maximum).

13. Difference between DELETE and TRUNCATE?

– Answer: DELETE removes rows one at a time and logs each delete, while TRUNCATE removes all rows in a table without logging individual row deletions. TRUNCATE is faster but cannot be rolled back.

14. What is a UNION in SQL?

– Answer: UNION is an operator used to combine the result sets of two or more SELECT statements. It removes duplicate rows between the various SELECT statements.

15. What is a cursor in SQL?

– Answer: A cursor is a database object used to retrieve, manipulate, and navigate through a result set one row at a time.

16. What is trigger in SQL?

– Answer: A trigger is a set of SQL statements that automatically execute or “trigger” when certain events occur in a database, such as INSERT, UPDATE, or DELETE.

17. Difference between clustered and non-clustered indexes?

– Answer: A clustered index determines the physical order of data in a table and can only be one per table. A non-clustered index, on the other hand, creates a logical order and can be many per table.

18. Explain the term ACID.

– Answer: ACID stands for Atomicity, Consistency, Isolation, and Durability.

WhatsAppJoin us on
WhatsApp!