SQL Test 2 (1) - Copy
SQL Test 2 (1) - Copy
Theory Questions
1. What is a relational database?
o Explain its structure and advantages.
2. What are SQL constraints?
o Describe different types of constraints like NOT
NULL, UNIQUE, CHECK, and DEFAULT.
3. What is the difference between UNION and UNION ALL?
o Explain how each operates with examples.
4. What is a view in SQL?
o Discuss its purpose and how it differs from a table.
5. What are stored procedures and triggers?
o Explain the differences and when to use each.
6. What is the significance of the EXPLAIN statement in SQL?
o Discuss how it helps in query optimization.
7. What is data integrity, and why is it important?
o Explain its types and how SQL enforces it.
8. What is the difference between DELETE, TRUNCATE,
and DROP?
o Discuss the implications of each operation.
9. What are aggregate functions, and how are they used?
o List some common aggregate functions with examples.
10. What is the purpose of the WHERE clause?
o Explain how it filters records in a SQL query.
Practical Questions
1. Write an SQL query to retrieve all employees from
the employees table who were hired after January 1, 2020.
2. Create a query to calculate the total sales from a sales table
grouped by each product.
3. Write an SQL statement to find all distinct job titles in
the employees table.
4. Create a query to join customers and orders tables and
display the customer names along with their order dates.
5. Write a query to update the salary of all employees in
the departments table by increasing it by 10%.
Aptitude Questions
1. If a table has 150 records and you apply a filter that
matches 30 of them, what percentage of the total records
will be returned?
2. In a dataset with 1000 records, if 100 records are deleted,
what will be the new total number of records?
3. If you have a table with 4 columns, how many unique
combinations of 2 columns can be selected?
4. In a situation where you have 200 records and you sort them
in descending order, how many comparisons might be
needed in the worst case?
5. If an index is applied to a column in a table, what effect does
it have on the performance of SELECT queries?
SQL Test for Freshers