Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Assignments BCA Part-II

Database Management System (DBMS)


SQL Commands
Tables to be used in the following questions are:

Table Name : dept

Attribute Name Attribute Type and width Integrity Constraints


Deptno Number(2) Primary key
Dname Char(20) Not Null
City Varchar(20)

Table Name : emp

Attribute Name Attribute Type and width Integrity Constraints


Empno Number(4) Primary Key
Ename Varchar(20) Not Null
Salary Number(6) Salary must be greater than 10000
Doj Date
mgr Number(4) Contains empno of immediate boss
Deptno Number(2) Refer Deptno of ‘dept’ table as foreign
key

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’.

You might also like