0% found this document useful (0 votes)
65 views4 pages

Lab Manual 2020-21

This document outlines a lab manual for a Database Management Systems course. It provides examples of creating tables, inserting sample data, and performing queries on the tables using commands like SELECT, JOIN, and functions. The tables created include DEPOSIT, BRANCH, CUSTOMERS, BORROW and others. Queries are provided to retrieve, manipulate and aggregate the data in various ways including filtering on dates, character patterns, math operations and more. The document aims to teach students to work with relational databases and SQL.

Uploaded by

Sujal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views4 pages

Lab Manual 2020-21

This document outlines a lab manual for a Database Management Systems course. It provides examples of creating tables, inserting sample data, and performing queries on the tables using commands like SELECT, JOIN, and functions. The tables created include DEPOSIT, BRANCH, CUSTOMERS, BORROW and others. Queries are provided to retrieve, manipulate and aggregate the data in various ways including filtering on dates, character patterns, math operations and more. The document aims to teach students to work with relational databases and SQL.

Uploaded by

Sujal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Gujarat Technological University

G H Patel College of Engineering and Technology


Department of Information Technology
Academic Year 2020-21 Semester – 1 Level - 2

3130703 – Database Management Systems


Lab Manual

1. To study DDL-create and DML-insert commands


CREATE TABLE DEPOSITE (ACTNO VARCHAR2(5) ,CNAME VARCHAR2(18) , BNAME VARCHAR2(18) , AMOUNT
NUMBER(8,2) ,ADATE DATE);

ACTNO CNAME BNAME AMOUNT ADATE


100 Anil VRCE 5000.00 1-MAR-95
101 Sunil AJNI 2500.00 4-JAN-96
102 Mehul KAROLBAGH 3500.00 17-NOV-95
103 Madhuri CHANDI 9607.00 17-DEC-95
104 Pramod M.G.ROAD 5700.00 27-MAR-96
105 Sandip ANDHERI 8600.00 31-MAR-96
106 Shivani VIRAR 7546.35 5-SEP-95
107 Kranti NEHRU PLACE 7890.45 2-JUL-95
108 Minu POWAI 8466.00 10-AUG-95
109 Shivam CHANDI 5800.00 11-MAY-97

CREATE TABLE BRANCH (BNAME VARCHAR2(18),CITY VARCHAR2(18));

BNAME CITY
VRCE Nagpur
AJNI Nagpur
KAROLBAGH Delhi
CHANDI Delhi
DHARAMPETH Nagpur
M.G.ROAD Banglore
ANDHERI Bombay
VIRAR Bombay
NEHRU PLACE Delhi
POWAI Bombay

CREATE TABLE CUSTOMERS (CNAME VARCHAR2(19) ,CITY VARCHAR2(18));

CNAME CITY
Anil Calcutta
Sunil Delhi
Mehul Baroda
Mandar Patna
Madhuri Nagpur
Pramod Nagpur
Sandip Surat
Shivani Bombay
Kranti Bombay
Naren Bombay

CREATE TABLE BORROW (LOANNO VARCHAR2(5), CNAME VARCHAR2(18), BNAME VARCHAR2(18), AMOUNT
NUMBER (8,2));
LOANNO CNAME BNAME AMOUNT
201 Anil VRCE 5000.00
206 Mehul AJNI 7000.00
311 Sunil DHARAMPETH 7500.00
321 Madhuri ANDHERI 8560.00
375 Pramod VIRAR 8000.00
481 Kranti NEHRU PLACE 6580.00

From the above given tables perform the following queries:


(1) Describe deposit, branch.
(2) Describe borrow, customers.
(3) List all data from table DEPOSIT.
(4) List all data from table BORROW.
(5) List all data from table CUSTOMERS.
(6) List all data from table BRANCH.
(7) Give account no and amount of depositors.
(8) Give name of depositors having amount greater than 4000.
(9) Give name of customers who opened account after date '1-12-96'.

2. Create table and insert sample data in tables.

Department (dept_no - number(3), dept_name - varchar2(12), city - varchar2(12))

dept_no dept_name city


10 Computer Chicago
15 Marketing Delhi
20 Finance Mumbai
25 Accounts Mumbai
30 Training Delhi

Employee (emp_no - Number(3), emp_name - Varchar2(30), emp_sal - Number(8,2), emp_comm - Number(6,1),


dept_no - Number(3), hire_date date)

emp_no emp_name emp_sal emp_comm dept_no hire_date


101 Smith 80000 20 01-JAN-06
102 Snehal 75000 3000 25 15-JUL-06
103 Adama 75000 0 20 12-MAR-06
104 Aman 57000 15 13-SEP-06
105 Anita 62000 16500 10 19-NOV-06
106 Sneha 67000 20000 10 21-DEC-06
107 Anamica 72000 30 03-JAN-07

Job (job_id - Varchar2(15), job_title - Varchar2(30), min_sal - Number(7,2), max_sal Number(7,2))

job_id dept_no job_name min_sal max_sal


IT_PROG 10 Programmer 40000 100000
MK_MGR 15 Marketing manager 9000 15000
FI_MGR 20 Finance manager 8200 12000
FI_ACC 25 Account 4200 9000
LEC 30 Lecturer 6000 17000
COMP_OP 10 Computer Operator 1500 3000
Manager (m_no - number(3), m_name - varchar2(12), dept_no - number(3)).

m_no m_name dept_no


105 Anita 10
104 Aman 15
103 Adama 20
102 Snehal 25
107 Anamika 30

(1) Retrieve all data from employee, jobs and deposit.


(2) Give details of account no. and deposited rupees of customers having account opened between dates 01-01-06
and 25-07-06.
(3) Display all jobs with minimum salary is greater than 4000.
(4) Display name and salary of employee whose department no is 20. Give alias name to name of employee.
(5) Display employee no, name and department details of those employee whose department lies in(10,20)

3. Perform queries involving predicates LIKE, BETWEEN, IN etc.


(1) Display all employee whose name start with ‘A’ and third character is ‘a’.
(2) Display name, number and salary of those employees whose name is 5 characters long and first three
characters are ‘Ani’.
(3) Display the non-null values of employees and also employee name second character should be ‘n’ and string
should be 5 character long.
(4) Display the null values of employee and also employee name’s third character should be ‘a’.

4. To perform various data manipulation commands, aggregate functions and sorting concept on all
created tables.
(1) List total deposit from deposit.
(2) List total loan from karolbagh branch
(3) Give maximum loan from branch VRCE.
(4) Count total number of customers.
(5) Count total number of customer’s cities.
(6) Create table supplier from employee with all the columns.
(7) Create table sup1 from employee with first two columns.
(8) Create table sup2 from employee with no data
(9) Insert the data into sup2 from employee whose second character should be ‘n’ and string should be 5
characters long in employee name field.
(10) Delete all the rows from sup1.
(11) Delete the detail of supplier whose sup_no is 103.
(12) Rename the table sup2.
(13) Destroy table sup1 with all the data.
(14) Update the value dept_no to 10 where second character of emp. name is ‘m’.
(15) Update the value of employee name whose employee number is 103.

5. To study Single-row functions.


(1) Write a query to display the current date. Label the column Date
(2) For each employee, display the employee number, job, salary, and salary increased by 15% and expressed as a
whole number. Label the column New Salary
(3) Modify your query no 4.2 to add a column that subtracts the old salary from the new salary. Label the column
Increase
(4) Write a query that displays the employee’s names with the first letter capitalized and all other letters
lowercase, and the length of the names, for all employees whose name starts with J, A, or M. Give each column an
appropriate label. Sort the results by the employees’ last names.
(5) Write a query that produces the following for each employee: <employee last name> earns <salary> monthly
(6) Display the name, hire date, number of months employed and day of the week on which the employee has
started. Order the results by the day of the week starting with Monday.
(7) Display the hire date of employee in a format that appears as seventh of June 1994 12:00:00 AM.
(8) Write a query to calculate the annual compensation of all employees (sal+comm).

6. Displaying data from Multiple Tables (join)


(1) Give details of customers ANIL.
(2) Give name of customer who are borrowers and depositors and having living city nagpur
(3) Give city as their city name of customers having same living branch.
(4) Write a query to display the last name, department number, and department name for all employees.
(5) Create a unique listing of all jobs that are in department 30. Include the location of the department in the
output
(6) Write a query to display the employee name, department number, and department name for all employees
who work in NEW YORK.
(7) Display the employee last name and employee number along with their manager’s last name and manager
number. Label the columns Employee, Emp#, Manager, and Mgr#, respectively.
(8) Create a query to display the name and hire date of any employee hired after employee SCOTT.

7. To apply the concept of Aggregating Data using Group functions.

(1) List total deposit of customer having account date after 1-jan-96.
(2) List total deposit of customers living in city Nagpur.
(3) List maximum deposit of customers living in bombay.
(4) Display the highest, lowest, sum, and average salary of all employees. Label the columns Maximum, Minimum,
Sum, and Average, respectively. Round your results to the nearest whole number.
(5) Write a query that displays the difference between the highest and lowest salaries. Label the column
DIFFERENCE.
(6) Create a query that will display the total number of employees and, of that total, the number of employees
hired in 1995, 1996, 1997, and 1998
(7) Find the average salaries for each department without displaying the respective department numbers.
(8) Write a query to display the total salary being paid to each job title, within each department.
(9) Find the average salaries > 2000 for each department without displaying the respective department numbers.
(10) Display the job and total salary for each job with a total salary amount exceeding 3000, in which excludes
president and sorts the list by the total salary.
(11) List the branches having sum of deposit more than 5000 and located in city bombay.

8. To solve queries using the concept of sub query.

(1) Write a query to display the last name and hire date of any employee in the same department as SCOTT.
Exclude SCOTT
(2) Give name of customers who are depositors having same branch city of mr. sunil.
(3) Give deposit details and loan details of customer in same city where pramod is living.
(4) Create a query to display the employee numbers and last names of all employees who earn more than the
average salary. Sort the results in ascending order of salary.
(5) Give names of depositors having same living city as mr. anil and having deposit amount greater than 2000
(6) Display the last name and salary of every employee who reports to ford.
(7) Display the department number, name, and job for every employee in the Accounting department.
(8) List the name of branch having highest number of depositors.
(9) Give the name of cities where in which the maximum numbers of branches are located.
(10) Give name of customers living in same city where maximum depositors are located.
(11) Give 10% interest to all depositors.
(12) Delete depositors of branches having number of customers from 1 to 3.
(13) Delete borrower of branches having average loan less than 1000.

9. To apply the concept of security and privileges.


10. To study Transaction control commands.
11. Write a cursor to select the five highest paid employees from the emp table.
12. Write a trigger to display the salary difference between the old values and new values.

You might also like