0% found this document useful (0 votes)
9 views6 pages

? 50 SQL Interview Questions & Answers - Free PDF! ?

The document provides a comprehensive overview of SQL concepts, including its definition, types of joins, and differences between various SQL commands like DELETE, TRUNCATE, and DROP. It also explains key concepts such as normalization, primary and unique keys, foreign keys, stored procedures, and transactions. Each concept is illustrated with examples to enhance understanding.

Uploaded by

azharmanihar26
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)
9 views6 pages

? 50 SQL Interview Questions & Answers - Free PDF! ?

The document provides a comprehensive overview of SQL concepts, including its definition, types of joins, and differences between various SQL commands like DELETE, TRUNCATE, and DROP. It also explains key concepts such as normalization, primary and unique keys, foreign keys, stored procedures, and transactions. Each concept is illustrated with examples to enhance understanding.

Uploaded by

azharmanihar26
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
You are on page 1/ 6

Page 1

Q: What is SQL?
A: SQL (Structured Query Language) is used to manage and manipulate relational databases.
Example: SELECT * FROM Employees; retrieves all employee records.

Q: What is the difference between DELETE, TRUNCATE, and DROP?


A: DELETE removes specific rows (can be rolled back), TRUNCATE removes all rows (cannot be
rolled back), DROP removes the table entirely. Example: DELETE FROM Users WHERE id=5;
removes only one user.

Q: What are the different types of SQL Joins?


A: Joins combine data from multiple tables: INNER JOIN (common records), LEFT JOIN (all from
left table), RIGHT JOIN (all from right table), FULL JOIN (all records). Example: SELECT Orders.*,
Customers.Name FROM Orders INNER JOIN Customers ON Orders.CustomerID = Customers.ID;

Q: What is an Index in SQL?


A: Indexes improve query performance by allowing faster data retrieval. Example: CREATE INDEX
idx_name ON Employees(Name); creates an index on the Name column.

Q: What is normalization in SQL?


A: Normalization organizes data to reduce redundancy and improve integrity. Example: Splitting
customer details and orders into separate tables follows normalization principles.

Q: What is the difference between Primary Key and Unique Key?


A: Primary Key uniquely identifies each row and cannot be NULL, while Unique Key ensures
uniqueness but allows one NULL value. Example: PRIMARY KEY (ID) vs. UNIQUE (Email).

Q: What is a stored procedure?


A: A stored procedure is a precompiled SQL block that executes logic. Example: CREATE
PROCEDURE GetUsers() AS BEGIN SELECT * FROM Users; END;

Q: What is a foreign key?


A: A foreign key enforces referential integrity between two tables. Example: Orders table has
CustomerID as a foreign key referencing Customers table.

Q: What is the difference between HAVING and WHERE?


A: WHERE filters rows before aggregation, HAVING filters after aggregation. Example: SELECT
Department, COUNT(*) FROM Employees GROUP BY Department HAVING COUNT(*) > 5;

Created by @arjunummavagol
Page 2

Q: What is a transaction in SQL?


A: A transaction is a unit of work executed as a whole. Example: BEGIN TRANSACTION; UPDATE
Accounts SET Balance = Balance - 100 WHERE ID = 1; COMMIT;

Q: What is SQL?
A: SQL (Structured Query Language) is used to manage and manipulate relational databases.
Example: SELECT * FROM Employees; retrieves all employee records.

Q: What is the difference between DELETE, TRUNCATE, and DROP?


A: DELETE removes specific rows (can be rolled back), TRUNCATE removes all rows (cannot be
rolled back), DROP removes the table entirely. Example: DELETE FROM Users WHERE id=5;
removes only one user.

Q: What are the different types of SQL Joins?


A: Joins combine data from multiple tables: INNER JOIN (common records), LEFT JOIN (all from
left table), RIGHT JOIN (all from right table), FULL JOIN (all records). Example: SELECT Orders.*,
Customers.Name FROM Orders INNER JOIN Customers ON Orders.CustomerID = Customers.ID;

Q: What is an Index in SQL?


A: Indexes improve query performance by allowing faster data retrieval. Example: CREATE INDEX
idx_name ON Employees(Name); creates an index on the Name column.

Q: What is normalization in SQL?


A: Normalization organizes data to reduce redundancy and improve integrity. Example: Splitting
customer details and orders into separate tables follows normalization principles.

Q: What is the difference between Primary Key and Unique Key?


A: Primary Key uniquely identifies each row and cannot be NULL, while Unique Key ensures
uniqueness but allows one NULL value. Example: PRIMARY KEY (ID) vs. UNIQUE (Email).

Q: What is a stored procedure?


A: A stored procedure is a precompiled SQL block that executes logic. Example: CREATE
PROCEDURE GetUsers() AS BEGIN SELECT * FROM Users; END;

Q: What is a foreign key?


A: A foreign key enforces referential integrity between two tables. Example: Orders table has

Created by @arjunummavagol
Page 3

CustomerID as a foreign key referencing Customers table.

Q: What is the difference between HAVING and WHERE?


A: WHERE filters rows before aggregation, HAVING filters after aggregation. Example: SELECT
Department, COUNT(*) FROM Employees GROUP BY Department HAVING COUNT(*) > 5;

Q: What is a transaction in SQL?


A: A transaction is a unit of work executed as a whole. Example: BEGIN TRANSACTION; UPDATE
Accounts SET Balance = Balance - 100 WHERE ID = 1; COMMIT;

Q: What is SQL?
A: SQL (Structured Query Language) is used to manage and manipulate relational databases.
Example: SELECT * FROM Employees; retrieves all employee records.

Q: What is the difference between DELETE, TRUNCATE, and DROP?


A: DELETE removes specific rows (can be rolled back), TRUNCATE removes all rows (cannot be
rolled back), DROP removes the table entirely. Example: DELETE FROM Users WHERE id=5;
removes only one user.

Q: What are the different types of SQL Joins?


A: Joins combine data from multiple tables: INNER JOIN (common records), LEFT JOIN (all from
left table), RIGHT JOIN (all from right table), FULL JOIN (all records). Example: SELECT Orders.*,
Customers.Name FROM Orders INNER JOIN Customers ON Orders.CustomerID = Customers.ID;

Q: What is an Index in SQL?


A: Indexes improve query performance by allowing faster data retrieval. Example: CREATE INDEX
idx_name ON Employees(Name); creates an index on the Name column.

Q: What is normalization in SQL?


A: Normalization organizes data to reduce redundancy and improve integrity. Example: Splitting
customer details and orders into separate tables follows normalization principles.

Q: What is the difference between Primary Key and Unique Key?


A: Primary Key uniquely identifies each row and cannot be NULL, while Unique Key ensures
uniqueness but allows one NULL value. Example: PRIMARY KEY (ID) vs. UNIQUE (Email).

Q: What is a stored procedure?

Created by @arjunummavagol
Page 4

A: A stored procedure is a precompiled SQL block that executes logic. Example: CREATE
PROCEDURE GetUsers() AS BEGIN SELECT * FROM Users; END;

Q: What is a foreign key?


A: A foreign key enforces referential integrity between two tables. Example: Orders table has
CustomerID as a foreign key referencing Customers table.

Q: What is the difference between HAVING and WHERE?


A: WHERE filters rows before aggregation, HAVING filters after aggregation. Example: SELECT
Department, COUNT(*) FROM Employees GROUP BY Department HAVING COUNT(*) > 5;

Q: What is a transaction in SQL?


A: A transaction is a unit of work executed as a whole. Example: BEGIN TRANSACTION; UPDATE
Accounts SET Balance = Balance - 100 WHERE ID = 1; COMMIT;

Q: What is SQL?
A: SQL (Structured Query Language) is used to manage and manipulate relational databases.
Example: SELECT * FROM Employees; retrieves all employee records.

Q: What is the difference between DELETE, TRUNCATE, and DROP?


A: DELETE removes specific rows (can be rolled back), TRUNCATE removes all rows (cannot be
rolled back), DROP removes the table entirely. Example: DELETE FROM Users WHERE id=5;
removes only one user.

Q: What are the different types of SQL Joins?


A: Joins combine data from multiple tables: INNER JOIN (common records), LEFT JOIN (all from
left table), RIGHT JOIN (all from right table), FULL JOIN (all records). Example: SELECT Orders.*,
Customers.Name FROM Orders INNER JOIN Customers ON Orders.CustomerID = Customers.ID;

Q: What is an Index in SQL?


A: Indexes improve query performance by allowing faster data retrieval. Example: CREATE INDEX
idx_name ON Employees(Name); creates an index on the Name column.

Q: What is normalization in SQL?


A: Normalization organizes data to reduce redundancy and improve integrity. Example: Splitting
customer details and orders into separate tables follows normalization principles.

Created by @arjunummavagol
Page 5

Q: What is the difference between Primary Key and Unique Key?


A: Primary Key uniquely identifies each row and cannot be NULL, while Unique Key ensures
uniqueness but allows one NULL value. Example: PRIMARY KEY (ID) vs. UNIQUE (Email).

Q: What is a stored procedure?


A: A stored procedure is a precompiled SQL block that executes logic. Example: CREATE
PROCEDURE GetUsers() AS BEGIN SELECT * FROM Users; END;

Q: What is a foreign key?


A: A foreign key enforces referential integrity between two tables. Example: Orders table has
CustomerID as a foreign key referencing Customers table.

Q: What is the difference between HAVING and WHERE?


A: WHERE filters rows before aggregation, HAVING filters after aggregation. Example: SELECT
Department, COUNT(*) FROM Employees GROUP BY Department HAVING COUNT(*) > 5;

Q: What is a transaction in SQL?


A: A transaction is a unit of work executed as a whole. Example: BEGIN TRANSACTION; UPDATE
Accounts SET Balance = Balance - 100 WHERE ID = 1; COMMIT;

Q: What is SQL?
A: SQL (Structured Query Language) is used to manage and manipulate relational databases.
Example: SELECT * FROM Employees; retrieves all employee records.

Q: What is the difference between DELETE, TRUNCATE, and DROP?


A: DELETE removes specific rows (can be rolled back), TRUNCATE removes all rows (cannot be
rolled back), DROP removes the table entirely. Example: DELETE FROM Users WHERE id=5;
removes only one user.

Q: What are the different types of SQL Joins?


A: Joins combine data from multiple tables: INNER JOIN (common records), LEFT JOIN (all from
left table), RIGHT JOIN (all from right table), FULL JOIN (all records). Example: SELECT Orders.*,
Customers.Name FROM Orders INNER JOIN Customers ON Orders.CustomerID = Customers.ID;

Q: What is an Index in SQL?


A: Indexes improve query performance by allowing faster data retrieval. Example: CREATE INDEX
idx_name ON Employees(Name); creates an index on the Name column.

Created by @arjunummavagol
Page 6

Q: What is normalization in SQL?


A: Normalization organizes data to reduce redundancy and improve integrity. Example: Splitting
customer details and orders into separate tables follows normalization principles.

Q: What is the difference between Primary Key and Unique Key?


A: Primary Key uniquely identifies each row and cannot be NULL, while Unique Key ensures
uniqueness but allows one NULL value. Example: PRIMARY KEY (ID) vs. UNIQUE (Email).

Q: What is a stored procedure?


A: A stored procedure is a precompiled SQL block that executes logic. Example: CREATE
PROCEDURE GetUsers() AS BEGIN SELECT * FROM Users; END;

Q: What is a foreign key?


A: A foreign key enforces referential integrity between two tables. Example: Orders table has
CustomerID as a foreign key referencing Customers table.

Q: What is the difference between HAVING and WHERE?


A: WHERE filters rows before aggregation, HAVING filters after aggregation. Example: SELECT
Department, COUNT(*) FROM Employees GROUP BY Department HAVING COUNT(*) > 5;

Q: What is a transaction in SQL?


A: A transaction is a unit of work executed as a whole. Example: BEGIN TRANSACTION; UPDATE
Accounts SET Balance = Balance - 100 WHERE ID = 1; COMMIT;

Created by @arjunummavagol

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy