✅ Part A: Multiple Choice Questions (20 × 1 = 20 Marks)
Q1. Which of the following is a valid SQL statement to retrieve all columns from a table named
employee?
A. GET * FROM employee;
B. SELECT ALL FROM employee;
C. SELECT * FROM employee;
D. SHOW * FROM employee;
Q2. What does the following query return?
SELECT COUNT(*) FROM department;
A. Total number of departments
B. Number of columns in the department table
C. All department names
D. Department with max count
Q3. Which constraint ensures that the values in a column are unique and not NULL?
A. PRIMARY KEY
B. FOREIGN KEY
C. CHECK
D. DEFAULT
Q4. Which of the following is a DML command?
A. CREATE
B. INSERT
C. DROP
D. ALTER
Q5. What is the result of:
SELECT 10 + NULL;
A. 10
B. NULL
C. 10+NULL
D. Error
Q6. Which SQL keyword is used to sort the result-set?
A. GROUP BY
B. HAVING
C. ORDER BY
D. SORT BY
Q7. Which of the following statements retrieves employees with salary greater than 50000?
A. SELECT * FROM employee WHERE salary > 50000;
B. GET * FROM employee WHEN salary > 50000;
C. FETCH FROM employee IF salary > 50000;
D. SELECT salary > 50000 FROM employee;
Q8. Which normal form eliminates partial dependency?
A. 1NF
B. 2NF
C. 3NF
D. BCNF
Q9. A foreign key in a table:
A. Must be a primary key in the same table
B. Links to a primary key in another table
C. Can contain duplicate values only
D. Cannot reference another table
Q10. Which clause is used with aggregate functions to filter grouped records?
A. WHERE
B. HAVING
C. GROUP BY
D. ORDER BY
Q11. Which of the following is not a valid SQL constraint?
A. PRIMARY KEY
B. NOT NULL
C. AUTO_INCREMENT
D. FOREIGN INDEX
Q12. What does TRUNCATE do in SQL?
A. Deletes specific rows
B. Removes all rows and can’t be rolled back
C. Drops the table
D. Resets column names
Q13. Which of these is a valid command to rename a table in SQL?
A. RENAME TABLE old_name TO new_name;
B. ALTER TABLE old_name RENAME TO new_name;
C. Both A and B
D. None of the above
Q14. A relation is in 3NF if:
A. It is in 2NF and no transitive dependency exists
B. It is in 1NF and partial dependency exists
C. It is in 2NF and every determinant is a candidate key
D. It has only atomic values
Q15. Which command is used to remove a table from a database?
A. DELETE
B. REMOVE
C. DROP
D. ERASE
Q16. The result of this SQL statement:
SELECT LENGTH('Wipro');
A. 4
B. 5
C. 6
D. Error
Q17. What is the default sorting order in ORDER BY clause?
A. DESC
B. ASC
C. Random
D. NULL
Q18. Which of the following is true about a view?
A. View stores data permanently
B. View can be indexed
C. View is a virtual table based on SQL SELECT
D. Views consume physical space
Q19. What will the following return?
SELECT ROUND(15.678, 1);
A. 15
B. 15.67
C. 15.7
D. 16
Q20. What is the role of GROUP BY?
A. Sorts rows
B. Groups rows with the same values
C. Deletes duplicate rows
D. Filters rows
✅ Part B: SQL Coding Questions (6 × 5 = 30 Marks)
Q21. Consider a table Employee(emp_id, emp_name, dept_id, salary)
Write an SQL query to display names of employees earning more than 60000.
Q22. Consider two tables:
Department(dept_id, dept_name)
Employee(emp_id, emp_name, dept_id)
Write an SQL query to list employee names along with their department names using JOIN.
Q23. Create a table Student with the following structure:
student_id – Integer, Primary Key
student_name – Varchar(50)
email – Varchar(100), should be unique
age – Integer, must be >= 18
Q24. Given a table Sales(sale_id, product_name, amount, sale_date), write an SQL query to find the
total sales amount for each product.
Q25. Write an SQL query to list the names of employees who are not assigned to any department
using a LEFT JOIN.
Q26. Write a query to create a table Books with fields:
book_id (primary key)
title (text, required)
author (text)
price (numeric, must be > 0)
published_year (optional)
✅ Part C: Short Theory Answers (2 × 5 = 10 Marks)
Q27. Explain the difference between:
DELETE
TRUNCATE
DROP
(With examples)
Q28. What is the difference between WHERE and HAVING clauses in SQL? Provide examples.