Professional Documents
Culture Documents
SQL Assignments
SQL Assignments
1. Create ‘dept’ table and ‘emp’ table with all the integrity constraints defined in the above
tables.
2. Show the structure of ‘emp’ table.
3. Add minimum 5 departments in ‘dept’ table.
4. Add minimum 10 employees with different departments in ‘emp’ table.
5. Show all the data from ‘emp’ table.
6. Add a new attribute ‘designation’ with char(15) in ‘emp’ table.
7. Fill the data in designation attribute.
8. Increase the width of designation by 5 characters.
9. Show data of those employees having salary>20000.
10. Show data of those employees whose ‘doj’ is not available.
11. Show data of employees of department number 103 having salary>25000.
12. Show data of employees whose salary is more than 20000 but less than 40000.
13. Show name and designation of employees from department no. 101, 103 and 105.
14. Display name of the employees and their department names.
15. Display list of employees working in ‘Jaipur’ city.
16. Display the department name and total salary of each department.
17. Display employee number, employee name and salary of all the employees. Include
those employees in the result who has not allotted any department.
18. Display the name of the employees and their manager’s name.
19. Increase the salary of all employees by 10%.
20. Display Employee Number, Employee Name and his/her age.
21. Display department wise list of employees.
22. Display total salary of each department.
23. Display number of employees working in each department.
24. Display employee number, employee name and salary of highest salary taker employee
from each department.
25. Increase the salary of those employees by 5% from department 103 having salary <
10000.
26. Display the second highest salary.
27. Remove data of employee number 1011 from ‘emp’ table.
28. Remove data of all those employees who do not have their salary.
29. Create a new table ‘dept2’ from ‘emp’ table. ‘dept2’ table must have only data of
employees of department no. 2.
30. Create a view ‘view_dept2’ from ‘emp’ table. ‘view_dept2’ must have only data of
employees of department no. 2.
31. Update the salary of all employees in ‘view_dept2’ by 5%. Also check whether the
parental table ‘emp’ is also updated or not.
32. Remove view ‘view_dept2’.