0% found this document useful (0 votes)
5 views2 pages

Essential SQL Interview Questions Guide

Uploaded by

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

Essential SQL Interview Questions Guide

Uploaded by

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

Certainly!

Here are some common SQL interview questions you might encounter:

1- What is SQL and its types?

SQL stands for Structured Query Language, used for managing relational databases. Its types include
DDL (Data Definition Language), DML (Data Manipulation Language), DCL (Data Control Language), and
TCL (Transaction Control Language).

2- What are the different types of SQL commands?


Common SQL commands include SELECT, INSERT INTO, UPDATE, DELETE, CREATE TABLE, ALTER TABLE,
DROP TABLE, among others.

3- What is a primary key and foreign key?


A primary key uniquely identifies each record in a table and ensures data integrity. A foreign key is a
column or a set of columns that establishes a relationship between tables. It refers to the primary key of
another table.

4- Explain the difference between INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL JOIN.
INNER JOIN returns records that have matching values in both tables.
LEFT JOIN returns all records from the left table and the matched records from the right table.
RIGHT JOIN returns all records from the right table and the matched records from the left table.
FULL JOIN returns all records when there is a match in either left or right table.

5- What is normalization and denormalization?


Normalization is the process of organizing data to minimize redundancy and dependency by dividing
large tables into smaller tables and defining relationships between them.
Denormalization is the process of adding redundant data to optimize query performance by avoiding
joins on related tables.

6- Explain ACID properties in the context of database transactions.


ACID stands for Atomicity, Consistency, Isolation, and Durability.
Atomicity ensures that all operations in a transaction are completed successfully or none at all.
Consistency ensures that the database remains in a consistent state before and after the transaction.
Isolation ensures that transactions are executed independently without interference from other
transactions.
Durability ensures that once a transaction is committed, its changes are permanent and survive system
failures.

7- What is a subquery?
A subquery is a query nested within another query. It can be used within WHERE, HAVING, or FROM
clauses to return data that meets specific criteria.
8- What is a stored procedure?
A stored procedure is a precompiled collection of SQL statements that perform a specific task. It is
stored in the database and can be executed multiple times with different parameters.

9- What is the difference between TRUNCATE and DELETE commands?


TRUNCATE removes all rows from a table without logging individual row deletions. It is faster than
DELETE but cannot be rolled back.
DELETE removes rows one by one and logs each row deletion. It can be rolled back using a transaction.

10- How do you optimize SQL queries?


Optimization techniques include indexing frequently accessed columns, avoiding unnecessary joins,
minimizing data retrieval, using appropriate data types, and analyzing query execution plans.

You might also like