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

SQL_Interview_Questions

SQL Interview Questions

Uploaded by

Deepthy rashmi
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)
6 views2 pages

SQL_Interview_Questions

SQL Interview Questions

Uploaded by

Deepthy rashmi
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/ 2

SQL Interview Questions with Definitions

1. What is SQL?
SQL (Structured Query Language) is a standard programming language used for managing and
manipulating relational databases. It allows users to query, insert, update, and delete data.

2. What is the difference between SQL and MySQL?


SQL is the language used to interact with databases, while MySQL is a relational database
management system (RDBMS) that uses SQL.

3. What are the different types of SQL commands?


• DDL (Data Definition Language) – CREATE, ALTER, DROP • DML (Data Manipulation Language)
– INSERT, UPDATE, DELETE • DQL (Data Query Language) – SELECT • DCL (Data Control
Language) – GRANT, REVOKE • TCL (Transaction Control Language) – COMMIT, ROLLBACK,
SAVEPOINT

4. What is the difference between WHERE and HAVING clause?


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

5. What is a primary key?


A primary key is a column (or set of columns) that uniquely identifies each row in a table. It cannot
have NULL values.

6. What is a foreign key?


A foreign key is a column that creates a relationship between two tables, referencing the primary
key in another table.

7. What is the difference between INNER JOIN and LEFT JOIN?


• INNER JOIN returns only matching rows from both tables. • LEFT JOIN returns all rows from the
left table and matching rows from the right table; NULL for non-matching rows.

8. Write a query to fetch all employees from the 'QA' department.


SELECT * FROM employees WHERE department = 'QA';

9. What is normalization?
Normalization is the process of organizing data to reduce redundancy and improve data integrity.

10. What is denormalization?


Denormalization is the process of combining tables to improve query performance, at the cost of
redundancy.

11. What is an index?


An index is a database object that improves query performance by allowing faster retrieval of rows.

12. What is the difference between clustered and non-clustered index?


• Clustered index determines the physical order of rows in a table. • Non-clustered index is stored
separately from the data and contains pointers to the data.

13. Write a query to find the second highest salary.


SELECT MAX(salary) FROM employees WHERE salary < (SELECT MAX(salary) FROM
employees);

14. What is the difference between DELETE, TRUNCATE, and DROP?


• DELETE removes rows based on a condition and can be rolled back. • TRUNCATE removes all
rows but keeps the structure, cannot be rolled back. • DROP removes the table structure and data
permanently.

15. What are SQL constraints?


Rules applied to columns to maintain data integrity: NOT NULL, UNIQUE, PRIMARY KEY,
FOREIGN KEY, CHECK, DEFAULT.

You might also like