0% found this document useful (0 votes)
41 views8 pages

Labplan DBMS

Uploaded by

enjoytime63
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)
41 views8 pages

Labplan DBMS

Uploaded by

enjoytime63
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

GUJARAT TECHNOLOGICAL UNIVERSITY

CE(07) /CSD(49)
DATABASE MANAGEMENT SYSTEMS
SUBJECT CODE: BE03000091
B.E. 3rd Semester
Practical [Link] and implement following schema and insert
data in tables.
(i) Create tables according to the following definition.

CREATE TABLE DEPOSIT (ACTNO VARCHAR(5),CNAME VARCHAR(18) , BNAME


VARCHAR(18), AMOUNT NUMERIC(8,2) ,ADATE DATE);

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

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

CREATE TABLE BORROW(LOANNO VARCHAR(5 ), CNAME VARCHAR(18), BNAME


VARCHAR(18), AMOUNT NUMERIC (8,2));

(ii) Insert the data as shown below.

DEPOSIT

ACTNO CNAME BNAME AMOUNT ADATE

100 ANIL VRCE 1000.00 1-MAR-95

101 SUNIL AJNI 5000.00 4-JAN-96

102 MEHUL KAROLBAGH 3500.00 17-NOV-95

104 MADHURI CHANDI 1200.00 17-DEC-95

105 PRMOD [Link] 3000.00 27-MAR-96

106 SANDIP ANDHERI 2000.00 31-MAR-96

107 SHIVANI VIRAR 1000.00 5-SEP-95

108 KRANTI NEHRU PLACE 5000.00 2-JUL-95

109 MINU POWAI 7000.00 10-AUG-95


BRANCH

VRCE NAGPUR

AJNI NAGPUR

KAROLBAGH DELHI

CHANDI DELHI

DHARAMPETH NAGPUR

[Link] BANGLORE

ANDHERI BOMBAY

VIRAR BOMBAY

NEHRU PLACE DELHI

POWAI BOMBAY

CUSTOMERS

ANIL CALCUTTA

SUNIL DELHI

MEHUL BARODA

MANDAR PATNA

MADHURI NAGPUR

PRAMOD NAGPUR

SANDIP SURAT

SHIVANI BOMBAY

KRANTI BOMBAY

NAREN BOMBAY
BORROW

LOANNO CNAME BNAME AMOUNT

201 ANIL VRCE 1000.00

206 MEHUL AJNI 5000.00

311 SUNIL DHARAMPETH 3000.00

321 MADHURI ANDHERI 2000.00

375 PRMOD VIRAR 8000.00

481 KRANTI NEHRU PLACE 3000.00

From the above given tables perform the following queries:

(1) Describe deposit, branch.


(2) Describe borrow, customers.
Practical 2. Implement DDL and DML commands.
1. List all data from table DEPOSIT.
2. List all data from table BORROW.
3. List all data from table CUSTOMERS.
4. List all data from table BRANCH.
5. Give account no and amount of depositors.
6. Give name of depositors having amount greater than 4000.
7. Give name of customers who opened account after date '1-12-95
8. Describe customer table

Practical 3. Implement data Constraints.


(1) create table Emp with the following fields and constraints.
Empno as primary key, deptno as foreign key, empname, role, role id, hire date,
manager no.
(2) create table dept having fields – deptno PRIMARY KEY, dept name, dept loc, job_id as
foreign key.
(3) Create table job having fields like job_id primary key, job_name,min_sal and max_sal.
(4) Insert records in all the tables as follows :

Emp_no Dept_no Name Role Role_id Hire date Manager


no.
101 20 Ward Salesman 7697 22-2-1995 102
102 20 Jones Manager 7839 15-6-1990
103 20 Martin Salesman 7697 23-4-1993 102
104 40 Blake Manager 7839 1-5-1992
105 10 Clark Manager 7839 2-10-1995
106 10 Scott Analyst 7565 9-12-1991 105
107 30 King President 7000 17-1-1994

Dept_no Dept Name Job_id Dept loc


10 Account IT_PROG New York
20 Research MK_MGR Delhi
30 Sales FI_MGR Chicago
40 Operations FI_ACC Boston

job_id job_name Min_sal max_sal


IT_PROG Programmer 4000
MK_MGR Marketing manager 9000 15000

FI_MGR Finance manager 8200 12000


FI_ACC Account 4200
LEC Lecturer 6000
COMP_OP Computer Operator 1500 3000

Write SQL statement of followings.


1. Add emp_address column in the emp table.
2. Drop emp_address column from emp table.
3. Modify deposit table with ACTNO character(5).
4. Update min_sal where the salary is blank.
5. Retrieve all data from emp, job and deposit.
6. Give details of account no. and deposited rupees of customers having account opened
between dates 01-01-96 and 31-08-96.
7. Display all jobs with minimum salary is greater than 4000.
8. Display name and salary of employee whose department no is 20. Give alias name to name
of employee.
9. Display employee no,name and department details of those employee whose department lies
in(10,20)

Practical 4. Perform value matching and pattern matching


conditions on any sample schema to retrieve specific data
based on given requirements.

(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’.
(5) What will be output if you are giving LIKE predicate as ‘%\_%’ ESCAPE ‘\’
Practical 5. To Perform various functions like
aggregate, numeric, string, conversion, date, set, sorting
operations to manipulate data effectively.
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’
10. and string should be 5 characters long in employee name field.

11. Delete all the rows from sup1.


12. Delete the detail of supplier whose sup_no is 103.
13. Rename the table sup2.
14. Destroy table sup1 with all the data.
15. Update the value dept_no to 10 where second character of emp. name is ‘m’.
16. Update the value of employee name whose employee number is [Link] a query to display
the current date. Label the column Date.
17. 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.
18. Modify your query no 5.(2) to add a column that subtracts the old salary from the new salary.
Label the column Increase.
19. 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
20. employees’ last names.
21. Write a query that produces the following for each
employee:
22. <employee last name> earns <salary> monthly
23. 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.
24. Display the hiredate of emp in a format that appears as 7th of June 1994 [Link] AM.
25. Write a query to calculate the annual compensation of all employees (sal+comm.).
Manipulating Data
(1) Give 10% interest to all depositors.
(2) Give 10% interest to all depositors having branch vrce
(3) Give 10% interest to all depositors living in nagpur and having branch city bombay.
(4) Write a query which changes the department number of all employees with empno
7788’s job to employee 7844’current department number.
(5) Transfer 10 Rs from account of anil to sunil if both are having same branch.
(6) Give 100 Rs more to all depositors if they are maximum depositors in their respective
branch.
(7) Delete depositors of branches having number of customers between 1 to 3.
(8) Delete deposit of vijay.
(9) Delete borrower of branches having average loan less than 1000.
Practical 6. 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.

Practical 7. 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.
Practical 8. Displaying data from Multiple Tables (join)
(11) Give details of customers ANIL.
(12) Give name of customer who are borrowers and depositors and having living city
nagpur
(13) Give city as their city name of customers having same living branch.
(14) Write a query to display the last name, department number, and department name
for all employees.
(15) Create a unique listing of all jobs that are in department 30. Include the location of
the department in the output
(16) Write a query to display the employee name, department number, and department
name for all employees who work in NEW YORK.
(17) 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.
(18) Create a query to display the name and hire date of any employee hired after
employee SCOTT.

(19)
Practical 9 Study & Implementation of database backup
& recovery commands. To study & Implementation of
Rollback, Commit ,Savepoint.

Practical 10. Study & Implementation of PL/SQL using


cursor and Triggers.

You might also like