4mca7 - Dbms Lab: List of Practicals
4mca7 - Dbms Lab: List of Practicals
List of Practicals
1. To study Basic SQL commands (create database, create table, use , drop, insert)
and execute the following queries using these commands:
a) Create a database named ‘ Employee’.
b) Use the database ‘Employee’ and create a table ‘Emp’ with attributes
‘ename’,’ecity’,’salary’,’enumber’,’eaddress’,’depttname’,’ccity’.
c) Create another table ‘Company’ with attributes ‘cname’, ccity’,’empnumber’ in the database
‘Employee’.
2. Creating users, assigning and revoking the roles and privileges to them.
a) Create user with any user name.
b) Assign privileges to users.
3. To study the viewing commands (select , update) and execute the following
queries using these commands:
a) Find the names of all employees who live in Delhi.
b) Increase the salary of all employees by Rs. 5,000.
c) Find the company names where the number of employees is greater than 10,000.
d) Change the Company City to Gurgaon where the Company name is ‘TCS’.
4. To study the commands to modify the structure of table (alter, delete) and execute the
following queries using these commands:
a) Add an attribute named ‘ Designation’ to the table ‘Emp’.
b) Modify the table ‘Emp’, Change the datatype of ‘salary’ attribute to float.
c) Drop the attribute ‘depttname’ from the table ‘emp’.
d) Delete the entries from the table ‘ Company’ where the number of employees are less than
500.
5. To study the commands that involve compound conditions (and, or, in , not in, between ,
not between , like , not like) and execute the following queries using these commands:
a) Find the names of all employees who live in ‘ Gurgaon’ and whose salary is between Rs. 20,000
and Rs. 30,000.
b) Find the names of all employees whose names begin with either letter ‘A’ or ‘B’.
c) Find the company names where the company city is ‘Delhi’ and the number of employees is
not between 5000 and 10,000.
d) Find the names of all companies that do not end with letter ‘A’.
6. To study the aggregate functions (sum, count, max, min, average) and execute the following
queries using these commands:
a) Find the sum and average of salaries of all employees in IT department.
b) Find the number of all employees who live in Delhi.
c) Find the maximum and the minimum salary in the HR department.
7. To study the grouping commands (group by, order by) and execute the following queries
using these commands:
a) List all employee names in descending order.
b) Find number of employees in each department where number of employees is greater than 5.
c) List all the department names where average salary of a department is Rs.10,000.
8. To study the commands involving data constraints and execute the following queries using
these commands:
a) Alter table ‘Emp’ and make ‘enumber’ as the primary key.
b) Alter table ‘Company’ and add the unique constraint.
c) Alter table ‘Company’ and add primary key constraint to column cname.
d) Create table ‘emp_details’ containing fields eno, cname and add foreign key constraints using
tables ‘Emp’ and ‘Company’.
9. To study the commands for aliasing and renaming and execute the following queries using
these commands:
a) Rename the name of table ‘Emp’ to ‘Emp1’.
b) Change the name of the attribute ‘ename’ to ‘empname’.
10.To study the commands for joins ( cross join, inner join, outer join) and execute the
following queries using these commands:
a) Retrieve the complete record of an employee and its company from both the table using joins.
b) List all the employees working in the company ‘TCS’.
11.To study the various set operations and execute the following queries using these
commands:
a) List the enumber of all employees who live in Delhi and whose company is in Gurgaon or if
both conditions are true.
b) List the enumber of all employees who live in Delhi but whose company is not in Gurgaon.
12.To study the various scalar functions and string functions ( power, square, substring,
reverse, upper, lower, concatenation) and execute the following queries using these
commands:
a) Reverse the names of all employees.
b) Change the names of company cities to uppercase.
c) Concatenate name and city of the employee.
13.To study the commands for views and execute the following queries using these
commands:
a) Create a view having ename and ecity.
b) In the above view change the ecity to ‘Delhi’ where ename is ‘John’.
c) Create a view having attributes from both the tables.
d) Update the above view and increase the salary of all employees of IT department by Rs.1000.
14.To study the commands involving indexes and execute the following queries:
a) Create an index with attribute ename on the table employee.
b) Create a composite index with attributes cname and ccity on table company.
c) Drop all indexes created on table company.
15.To study the conditional controls and case statement in PL-SQL and execute the following
queries:
a) Calculate the average salary from table ‘Emp’ and print increase the salary if the average
salary is less that 10,000.
b) Print the deptno from the employee table using the case statement if the deptname is
‘Technical’ then deptno is 1, if the deptname is ‘HR’ then the deptno is 2 else deptno is 3.
16.To study procedures and triggers in PL-SQL and execute the following queries:
a) Create a trigger on table emp which will check and change the salary value of a employee to
5000 if 1000 or less is inserted. Trigger will get fired before inserting a new record to a table.
Practical In-charge
Prof. Preeti Deshmukh Prof. Amit Pimprikar