0% found this document useful (0 votes)
7 views

Final Dbms Lab Manual

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Final Dbms Lab Manual

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 55

PARUL INSTITUTE OF ENGINEERING & TECHNOLOGY

Database Management System LAB Manual(303105204)

SEM-3rd, YEAR-2nd
B.TECH-CSE BDA-2

ENROLLMENT ID:2303031250120
PRACTICAL: 1
1. What is DBMS? Explain advantages of DBMS over FPS.
Ans: DBMS stands for Database Management System. DBMS helps to maintain the data in
tables and records which is more systematic than FPS (File Processing System). The advantages
of DBMS over FPS are as follows:
1. Data redundancy and inconsistency.
2. Data sharing.
3. Data concurrency.
4. Data searching.
5. Data integrity.
6. Data security.
7. Data backup.
8. Easy maintenance.

2. List 15 applications of the Database. Explain any 2 how Database can be helpful
in managing that application.
Ans: The 15 applications of the Database are follows:
1. Banking.
2. School(Students and Staff’s Details).
3. Human resources management.
4. Manufacturing Sector (ProductDetails).
5. Supermarket.
6. Library.
7. Railway Reservation System.
8. Credit Card Exchange.
9. Social Media Services.
10. Airline Reservation System.
11. Health care Sector.
12. Online Shopping.
13. Agriculture Fields.
14. Telecommunication Sector.
15. Military Purpose.

PAGE:1
PARUL INSTITUTE OF ENGINEERING & TECHNOLOGY
Database Management System LAB Manual(303105204)

SEM-3rd, YEAR-2nd
B.TECH-CSE BDA-2

ENROLLMENT ID:2303031250120
Railway and Airline Reservation System: It keeps the records of ticket bookings,arrival time,
departure time, time delay, and even the seat no. of the airplane or train.

Library Management System: There are thousands of books in the library, so it is very
important to keep are cord of the details of each book.Hand written record scanb eproven are
alhassle when we have to manage large no of books, using DBMS all the details of each book
such as name, author’s name, number of pages, availability, quantity, etc., can be managed
productively.

3. Create the database for the following:


A. Student Details using Excel
B. Employees Details using MS Access
C. Facebook using Excel

A. Student Details using Excel

B. Employees Details using MS Access

C. Face book using Excel


PAGE:2
PARUL INSTITUTE OF ENGINEERING & TECHNOLOGY
Database Management System LAB Manual(303105204)

SEM-3rd, YEAR-2nd
B.TECH-CSE BDA-2

ENROLLMENT ID:2303031250120

PAGE:3
PARUL INSTITUTE OF ENGINEERING & TECHNOLOGY
Database Management System LAB Manual(303105204)

SEM-3rd, YEAR-2nd
B.TECH-CSE BDA-2

ENROLLMENT ID:2303031250120
PRACTICAL: 2
Create following Tables:
Important Instructions:
• Use varchar2(30) data type for Alphanumeric Characters and Special Symbols ,number data
type for Numbers, date Data type for Date.
• Use same table and column name(Capital and Small Case)as mentioned in this file.
• Insert proper data(Capital and Small Case)as mentioned in this file.
1.Employee:
For creating table

For inserting values

After selecting table

PAGE:4
PARUL INSTITUTE OF ENGINEERING & TECHNOLOGY
Database Management System LAB Manual(303105204)

SEM-3rd, YEAR-2nd
B.TECH-CSE BDA-2

ENROLLMENT ID:2303031250120

2.Work:
For creating table

For inserting values

After selecting table

3.Company:
For creating table

PAGE:5
PARUL INSTITUTE OF ENGINEERING & TECHNOLOGY
Database Management System LAB Manual(303105204)

SEM-3rd, YEAR-2nd
B.TECH-CSE BDA-2

ENROLLMENT ID:2303031250120
For inserting values

After selecting table

4.Manager:
For creating table

For inserting values

PAGE:6
PARUL INSTITUTE OF ENGINEERING & TECHNOLOGY
Database Management System LAB Manual(303105204)

SEM-3rd, YEAR-2nd
B.TECH-CSE BDA-2

ENROLLMENT ID:2303031250120
After selecting table

5.Sailors
For creating table

For inserting values

PAGE:7
PARUL INSTITUTE OF ENGINEERING & TECHNOLOGY
Database Management System LAB Manual(303105204)

SEM-3rd, YEAR-2nd
B.TECH-CSE BDA-2

ENROLLMENT :2303031250120
After selecting table

6.Reserves:
For creating table

For inserting values

PAGE:8
PARUL INSTITUTE OF ENGINEERING & TECHNOLOGY
Database Management System LAB Manual(303105204)

SEM-3rd, YEAR-2nd
B.TECH-CSE BDA-2

ENROLLMENT ID:2303031250120

After selecting table

7.Boats:
For creating table

For selecting values

After selecting table

PAGE:9
PARUL INSTITUTE OF ENGINEERING & TECHNOLOGY
Database Management System LAB Manual(303105204)

SEM-3rd, YEAR-2nd
B.TECH-CSE BDA-2

ENROLLMENT :2303031250120

8.Client:
For creating table

For inserting values

After selecting table


PARUL INSTITUTE OF ENGINEERING & TECHNOLOGY
Database Management System LAB Manual(303105204)

SEM-3rd, YEAR-2nd
B.TECH-CSE BDA-2

ENROLLMENT ID:2303031250120
9.Product;
For creating table

For inserting values

PAGE:11
PARUL INSTITUTE OF ENGINEERING & TECHNOLOGY
Database Management System LAB Manual(303105204)

SEM-3rd, YEAR-2nd
B.TECH-CSE BDA-2

ENROLLMENT ID:2303031250120
After selecting table

10.Salesman:
For creating table

For inserting values

PAGE:12
PARUL INSTITUTE OF ENGINEERING & TECHNOLOGY
Database Management System LAB Manual(303105204)

SEM-3rd, YEAR-2nd
B.TECH-CSE BDA-2

ENROLLMENT ID:2303031250120
After selecting table

11.Sales order:
For creating table

For inserting values

PAGE:13
PARUL INSTITUTE OF ENGINEERING & TECHNOLOGY
Database Management System LAB Manual(303105204)

SEM-3rd, YEAR-2nd
B.TECH-CSE BDA-2

ENROLLMENT ID:2303031250120
After selecting table

12.Sales order_Details
For creating table

For inserting values

PAGE:14
PARUL INSTITUTE OF ENGINEERING & TECHNOLOGY
Database Management System LAB Manual(303105204)

SEM-3rd, YEAR-2nd
B.TECH-CSE BDA-2

ENROLLMENT ID:2303031250120

After selecting table

13.Deposit
For creating table

For inserting values

PAGE:15
PARUL INSTITUTE OF ENGINEERING & TECHNOLOGY
Database Management System LAB Manual(303105204)

SEM-3rd, YEAR-2nd
B.TECH-CSE BDA-2

ENROLLMENT ID:2303031250120
After selecting table

14.Borrow
For creating table

For inserting values

After selecting table

PAGE:16
PARUL INSTITUTE OF ENGINEERING & TECHNOLOGY
Database Management System LAB Manual(303105204)

SEM-3rd, YEAR-2nd
B.TECH-CSE BDA-2

ENROLLMENT ID:2303031250120

15.Branch
For creating table

For inserting values

After selecting table

PAGE:17
PARUL INSTITUTE OF ENGINEERING & TECHNOLOGY
Database Management System LAB Manual(303105204)

SEM-3rd, YEAR-2nd
B.TECH-CSE BDA-2

ENROLLMENT ID:2303031250120

16.Customers
For creating table

For inserting values

PAGE:18
PARUL INSTITUTE OF ENGINEERING & TECHNOLOGY
Database Management System LAB Manual(303105204)

SEM-3rd, YEAR-2nd
B.TECH-CSE BDA-2

ENROLLMENT ID:2303031250120
After selecting table

PAGE:19
PARUL INSTITUTE OF ENGINEERING & TECHNOLOGY
Database Management System LAB Manual(303105204)

SEM-3rd, YEAR-2nd
B.TECH-CSE BDA-2

ENROLLMENT ID:2303031250120
PRACTICAL: 3
Simple Queries
(1) Describe deposit, branch.
- describe deposit_sajid;
- describe branch_sajid;

2.Describe borrow, customers.


- describe borrow_sajid;
- describe customers_sajid;

(3)List all data from table DEPOSIT.


select * from deposit_sajid;

PAGE:20
PARUL INSTITUTE OF ENGINEERING & TECHNOLOGY
Database Management System LAB Manual(303105204)

SEM-3rd, YEAR-2nd
B.TECH-CSE BDA-2

ENROLLMENT ID:2303031250120
(4)List all data from table BORROW.

(5)List all data from table customers.

(6). List all data from table borrow.


select * from branch_ sajid;

PAGE:21
PARUL INSTITUTE OF ENGINEERING & TECHNOLOGY
Database Management System LAB Manual(303105204)

SEM-3rd, YEAR-2nd
B.TECH-CSE BDA-2

ENROLLMENT ID:2303031250120
(7) Describe the details of Loan for customers.
select act_no,amount from deposit_sajid1;

(8)list all data from sailors.


Select* from sailors_sajid1;

(9)List Boat Name and its colour


Select bname,color from boats_sajid;

PAGE:22
PARUL INSTITUTE OF ENGINEERING & TECHNOLOGY
Database Management System LAB Manual(303105204)

SEM-3rd, YEAR-2nd
B.TECH-CSE BDA-2

ENROLLMENT ID:2303031250120
(10)List Employee name and its city.

(11). List all the details of Clients.

(12).Describe various products and its price.

(13).Describe the sailor's name, age and its rating.


Select sname,age,rating from sailors_sajid;

PAGE:23
PARUL INSTITUTE OF ENGINEERING & TECHNOLOGY
Database Management System LAB Manual(303105204)

SEM-3rd, YEAR-2nd
B.TECH-CSE BDA-2

ENROLLMENT ID:2303031250120
(14).Describe the managers of various employees.

(15).Describe the details of Loan for customers.

Select * from borrow_sajid;

(16).Describe the date of travel of various sailors.

Select * from reserves_sajid;

PAGE:24
PARUL INSTITUTE OF ENGINEERING & TECHNOLOGY
Database Management System LAB Manual(303105204)

SEM-3rd, YEAR-2nd
B.TECH-CSE BDA-2

ENROLLMENT ID:2303031250120

PRACTICAL: 4
Simple Queries:
(1) Give name of deposit or shaving amount greater than 4000.

(2) List the employees having salary less than 2200.


SELECT * FROM work_ sajid where salary>22000;

(3) List the sailors having age more than 25.


select Sname from sailors_ sajid1 where age>25;

(4) List the boats travelling on 10-oct-98


select bid from reserves_ sajid where day = '10-oct-98';

PAGE:25
PARUL INSTITUTE OF ENGINEERING & TECHNOLOGY
Database Management System LAB Manual(303105204)

SEM-3rd, YEAR-2nd
B.TECH-CSE BDA-2

ENROLLMENT ID:2303031250120

(5) List the details of boat “Interlake”.

(6) List the details of the red colore dboat.


SELECT * FROM boats_ sajid where color='Red';

(7) List the details of clients whose city is Mumbai


SELECT * FROM client_ sajid1 where city='Mumbai';

PAGE:26
PARUL INSTITUTE OF ENGINEERING & TECHNOLOGY
Database Management System LAB Manual(303105204)

SEM-3rd, YEAR-2nd
B.TECH-CSE BDA-2

ENROLLMENT ID:2303031250120

(8) List Client Name , due balance and city of the clients having balance greater than 1500.
SELECTname, city, baldue FROM client_ sajid where baldue>1500;

(9) Describe the details of products having selling price less than 500.

(10) List the products for which quantity ordered is less than 120 and cost price is greater than 250.

PAGE:27
PARUL INSTITUTE OF ENGINEERING & TECHNOLOGY
Database Management System LAB Manual(303105204)

SEM-3rd, YEAR-2nd
B.TECH-CSE BDA-2

ENROLLMENT ID:2303031250120

(11) Display account details having amount greater 2200.

(12) Display all the customers staying in Nagpur

(13) Display the names of sailors having rating greater than 7


SELECT sname FROM sailors_ sajid where rating>7;

(14) Display the orders made in the month of June

PAGE:28
PARUL INSTITUTE OF ENGINEERING & TECHNOLOGY
Database Management System LAB Manual(303105204)

SEM-3rd, YEAR-2nd
B.TECH-CSE BDA-2

ENROLLMENT ID:2303031250120
(15). List all the accounts created in the month of March.
SELECT * FROM Deposit_sajid1 WHERE Dates = '1-MAR-95' OR Dates = '27-MAR-96' OR Dates = '31-MAR-
96';

PAGE:29
PARUL INSTITUTE OF ENGINEERING & TECHNOLOGY
Database Management System LAB Manual(303105204)

SEM-3rd, YEAR-2nd
B.TECH-CSE BDA-2

ENROLLMENT ID:2303031250120
PRACTICAL: 5

(1) Display all customers whose name start with ‘M’.

(2) Display all the customers whose name ends with ‘L’.

(3) Display all loan details whose branch starts with ‘A’.

(4) Display the details of sailors whose name is minimum 6 characters long.
SELECT * FROM sailors_ sajid where length(Sname)>=6;

PAGE:30
PARUL INSTITUTE OF ENGINEERING & TECHNOLOGY
Database Management System LAB Manual(303105204)

SEM-3rd, YEAR-2nd
B.TECH-CSE BDA-2

ENROLLMENT ID:2303031250120

(5) Display the details of Employees whose address starts with ‘S’.

(6) List the details of the boat ending with ‘e’.

(7).List the details of clients having ‘h’ as a 3rd character in his/her name.

Select * from client_sajid where name like’_h’;

PAGE:31
PARUL INSTITUTE OF ENGINEERING & TECHNOLOGY
Database Management System LAB Manual(303105204)

SEM-3rd, YEAR-2nd
B.TECH-CSE BDA-2

ENROLLMENT ID:2303031250120
(8).List Client Name, due balance and city whose pin code starts with 4.

(9).List all customers whose city contains ‘a’ as second character.

(10).List client names and city whose state has ‘a’ as fourth or fifth character .

Select name,city from client_sajid where state like’___a%’ or state like’___a%’;

PAGE:32
Faculty of Engineering & Technology

Database Management System (303105203)


B.Tech CSE 2 ndYear 3 rdSemester

Enrollment no: 2303031250120

PRACTICAL: 06
Aim: “Aggregate Functions & DML” Queries
1. List total deposit from deposit.
• SELECT SUM(Amount) AS Total_Deposit_sajid FROM Deposit_sajid;

2. Give maximum loan given to the customer.


• SELECT MAX(Amount) AS MaximumLoan FROM Borrow_sajid;

3. Describe the average age of all the sailors.


• SELECT AVG(Age) AS Average_Age FROM Sailors_sajid;

4. Count total number of customers.


• SELECT COUNT(*) AS Total_Customers_sajid FROM Customers_sajid;

1
Faculty of Engineering & Technology

Database Management System (303105203)


B.Tech CSE 2 ndYear 3 rdSemester
Enrollment no: 2303031250120

5. Count total number of customer’s cities


• SELECT COUNT(DISTINCT City) AS Total_Cities FROM Customers_sajid;

6. Display total target for the salesman


SELECT SUM (Tgt) AS Total_Target FROM Salesman_sajid;

7. Update the salary of the employee having 10000 to 11500 .


 UPDATE Work SET Salary=11500 WHERE Salary=10000;

8. Update the city of client from Bangalore to Bengaluru


• UPDATE Client SET City='Bengaluru' WHERE City='Bangalore';

9. Give the 15% hike in the salary of all the Employees. Rename that column to

“New Salary”
• SELECT Salary*1.15 AS "NewSalary"from Work_sajid;

2
Faculty of Engineering & Technology

Database Management System (303105203)


B.Tech CSE 2 ndYear 3 rdSemester
Enrollment no: 2303031250120

10. Increase the sell price of all products by 20% and label new column as “New
Sell Price”.

• Select Sell_price*1.15 AS "New_Sell_Price" from Product_sajid;

3
Faculty of Engineering & Technology

Database Management System (303105203)

B.Tech CSE 2ndYear 3rdSemester

ERP NO :2303031250120

PRACTICAL: 07
Aim: “Join” Queries
1. Find the salary of Adam.
 SELECT Salary FROM Work _sajid WHERE Empname ='Adam';

2. Display the sailor’s details whose boat is booked for 9th May, 98.
 SELECT S.* FROM Sailors_sajid S JOIN Reserves_sajid R ON S.Sid = R.Sid
WHERE R.Day = '9-May-98';

3. Display the day of ride and sailor name for boat 103.
 SELECT R.Day,S.Sname FROM Reserves_sajid R JOIN Sailors_sajid S ON
R.Sid=S.Sid WHERE R.Bid=103;

45
5
Faculty of Engineering & Technology

Database Management System (303105203)

B.Tech CSE 2ndYear 3rdSemester

ERP NO :2303031250120

4. Display the sailor name and its age for Red colored and 101 boat.
 SELECT S.Sname,S.Age FROM Sailors S JOIN Reserves R ON S.Sid=R. Sid JOIN Boats B
ON R. Bid=B.Bid WHERE B.Color='Red'OR B.Bid=101;

5. Display the sailor details whose boat is never booked.


 SELECT S.*FROM Sailors S LEFT JOIN Reserves R ON S.Sid=R. Sid WHERE R.Sid IS
NULL;

45
5
Faculty of Engineering & Technology

Database Management System (303105203)

B.Tech CSE 2ndYear 3rdSemester

ERP NO :2303031250120
6. Display the sailor name that has Red or Green Boat.
 SELECT DISTINCT S.Sname FROM Sailors_sajid S JOIN Reserves_sajid R ON S. Sid =
R. Sid JOIN Boats_sajid B ON R. Bid = B. Bid WHERE B.Color IN('Red','Green');

7. Display all sailor details and boat details and who has Interlake boat
 SELECT S.*, B.* FROM Sailors_sajid S JOIN Reserves_sajid R ON S.Sid=R.Sid JOIN
Boats_sajid B ON R. Bid = B. Bid WHERE B. Bname = 'Interlake';

45
5
Faculty of Engineering & Technology

Database Management System (303105203)

B.Tech CSE 2ndYear 3rdSemester

ERP NO :2303031250120

8. Display sailor’s rating with boat details or the trip on 10th October, 98.
SELECT S.Rating, B.Bid, B.Bname, B.Color FROM Sailors_sajid S JOIN Reserves_sajid R ON S.Sid =
R.Sid JOIN Boats_sajid B ON R.Bid = B.Bid WHERE R.Day = '10-Oct-98';

9. Display the sailor id and name whose age is more than 42 or who has
Blue colored boat.
 SELECT S.Sid,S.Sname FROM Sailors_sajid S JOIN Reserves_sajid R ON S.Sid=R. Sid
JOIN Boats_sajid B ON R. Bid=B.Bid WHERE S.Age>42 OR B. Color = 'Blue';

10. Display name and rating of sailor whose boat name is Clipper.
 SELECT S.Sname,S.Rating FROM Sailors S JOIN Reserves R ON S.Sid=R.Sid JOIN Boats
B ON R. Bid = B. Bid WHERE B. Bname = 'Clipper';

45
5
Faculty of Engineering & Technology

Database Management System (303105203)

B.Tech CSE 2ndYear 3rdSemester

ERP NO :2303031250120

11. List products whose selling price is more than 500 and less than equal to 750.
 SELECT DSCR,Sell_Price FROM Product_sajid WHERE Sell_Price>500 AND
Sell_Price<=750;

12. Describe the second highest salary of an employee.


 SELECT MAX(Salary) AS Second_Highest_Salary FROM Work_sajid WHERE
Salary<(SELECT MAX(Salary)FROM Work);

13. Display the date of travel and sailor’s name whose age is between 35 and 65.
 SELECT R.Day AS Date_Of_Travel,S.Sname AS Sailor_Name FROM Sailors_sajid
S JOIN Reserves_sajid R ON S.Sid=R. Sid WHERE S.Age BETWEEN 35 AND 65;

45
5
Faculty of Engineering & Technology

Database Management System (303105203)

B.Tech CSE 2ndYear 3rdSemester

ENROLLMENT NO: 2303031250120

PRACTICAL: 08
Aim: “Join” Queries
1. Display all the employee name and the city where they work.
 SELECT Empname,City from Employee_sajid;

2. Display the employee name and company’s name having salary more than 15000.
 SELECT Empname,Cmpname from Work_sajid where salary>15000;

3. Find the average rating and age of all sailors.


 SELECT avg(Rating),avg(Age)from Sailors_sajid;
Faculty of Engineering & Technology

Database Management System (303105203)

B.Tech CSE 2ndYear 3rdSemester

ENROLLMENT NO: 2303031250120

4. List various products available.


 SELECT dscr from Product_sajid;

5. Display the names of salesman who have salary more than 2850.
 SELECT Name from Salesman_sajid where Amt>2850;

6. Change the cost price of Trousers to 950.


 Update Product_sajid set Cost_price=950 where Dscr='Trousers';
Faculty of Engineering & Technology

Database Management System (303105203)

B.Tech CSE 2ndYear 3rdSemester

ENROLLMENT NO: 2303031250120

7. List all the clients having “a” as a second character in their names.
 Select Name from Client where Name like'_a%';

8. List all the products whose Qty on Hand is less than Reorderlvl.
 Select Dscr from Product where 'Qty'<'Reorder_Lvl';

9. Print the description and total qty sold for each product.
 Select Dscr,Qty from Product_sajid;
Faculty of Engineering & Technology

Database Management System (303105203)

B.Tech CSE 2ndYear 3rdSemester

ENROLLMENT NO: 2303031250120

1. Find out all the products which have been sold to “Ivan Bayross”.
• Select DISTINCT P.Dscr FROM Product P JOIN Salesorder_Details SD ON P.Pr_no =
SD.Pr_no JOIN Salesorder SO ON SD.Od_no = SO.Od_no JOIN Client C ON SO.Cl_no = C.Cl_no
WHERE C.Name = 'IvanBayross';

13.Find the names of all clients who have purchased Trousers.


• Select DISTINCT C.Name FROM Client C JOIN Salesorder SO ON C.Cl_no = SO.Cl_no
JOIN Salesorder_Detail;

14. Find the products and their quantities for the orders placed by client C00001

and C00002.
• Select P.Dscr, SD.Qty_order FROM Client_sajid C JOIN Salesorder SO ON C.Cl_no =
SO.Cl_no JOIN Salesorder_Details_sajid SD ON SO.Od_no = SD.Od_no JOIN Product_sajid P
ON SD.Pr_no = P.Pr_no WHERE C.Cl_no IN ('C00001', 'C00002');
Faculty of Engineering & Technology

Database Management System (303105203)

B.Tech CSE 2ndYear 3rdSemester

ENROLLMENT NO: 2303031250120


15.List the client details who place order no. O19001.
• Select C.* FROM Client_sajid C JOIN Salesorder_sajid SO ON C.Cl_no
=SO.Cl_no WHERE SO.Od_no = 'O19001';
Faculty of Engineering & Technology

Database Management System (303105203)

B.Tech CSE 2ndYear 3rdSemester

ENROLLMENT NO: 2303031250120

PRACTICAL: 09
Aim: “Miscellaneous”Queries
1. Find the average rate for each Order.
 SELECT od_no , avg(rate) FROM salesorder_Details_sajid GROUP BY Od_no ;

2. Give the loan details of all the customers.


 SELECT * FROM Borrow_Sajid;

3. Find List the customer name having loan account in the same branch city they
live in.
 SELECT borrow.cname , branch.bname , branch.city from borrow inner join branch on
borrow.bname = branch.bname;
Faculty of Engineering & Technology

Database Management System (303105203)

B.Tech CSE 2ndYear 3rdSemester

ENROLLMENT NO: 2303031250120

4. Provide the loan details of all the customers who have opened their accounts
after August’95.
 SELECT D.Cname, D.Bname, D.Amount, D.Dates FROM Deposit_sajid D JOIN
Customers_sajid C ON D.Cname = C.Cname WHERE TO_DATE(D.Dates, 'DD-MON-YY') >
TO_DATE('10-AUG-95', 'DD-MON-YY');

5. List the order information for client C00001 and C00002.


 SELECT O.* from Salesorder S inner join Salesorder_Details O on S.Od_no=O.Od_nowhere
S.Cl_no='C00001' or S.Cl_no='C00002';

6. List all the information for the orders placed in the month of June
 SELECT *FROM SALESORDER _SAJID WHERE EXTRACT(MONTH FROM O_dat) = 6;
Faculty of Engineering & Technology

Database Management System (303105203)

B.Tech CSE 2ndYear 3rdSemester

ENROLLMENT NO: 2303031250120


7. List the details of clients who do not stay in Maharashtra.
 SELECT * from Client_sajid where not State='Maharashtra';

8. Determine the maximum and minimum product price. Rename the output as
“Max_Price” and “Min_Price”.
 SELECT min(Cost_Price) Min_Price,max(Cost_Price) Max_Price from Product;

9. ount the number of products having price less than or equal to 500.
 SELECT count(*) from Product_sajid where Cost_Price<=500;

10. List the order number and the day on which client placed an order.
 SELECT Od_no,O_dat from Salesorder_sajid
Faculty of Engineering & Technology

Database Management System (303105203)

B.Tech CSE 2ndYear 3rdSemester

ENROLLMENT NO: 2303031250120

11. List the month and the date on which an order is to be delivered.
 SELECT od_no,extract(Month from D_dat) Month, extract(Day from D_dat)Day from
Salesorder_sajid;

12. List the the date, 25 days after today’s date.


 SELECT SYSDATE+25 Day_After from Dual;
Faculty of Engineering & Technology

Database Management System (303105203)

B.Tech CSE 2ndYear 3rdSemester

ENROLLMENT NO: 2303031250120

13. Find the total of all the billed orders in the month of June.
 SELECT count(Od_no) from Salesorder_sajid where O_dat like '%JUN%';

14. List the products and orders from customers who have ordered less than 5 units
of “Pull Overs”
 SELECT SD.Od_no, SD.Pr_no, SD.Qty_order, P.Dscr FROM Salesorder_Details SD JOIN
Product P ON SD.Pr_no = P.Pr_no WHERE P.Dscr = 'PullOvers' AND SD.Qty_order < 5;

15. Find the list of products and orders placed by “Ivan Bayrosss” and “Mamta
Muzumdar”.
 SELECT so.Od_no, sod.Pr_no,C.Name FROM Client_sajid c JOIN Salesorder_sajid so
ON c.Cl_no = so.Cl_no JOIN Salesorder_Details_sajid sod ON so.Od_no = sod.Od_no WHERE
c.Name IN ('IvanBayross', 'MamtaMuzumdar');
Faculty of Engineering & Technology

Database Management System (303105203)

B.Tech CSE 2ndYear 3rdSemester

ENROLLMENT NO: 2303031250120

16. List the clients who placed order before June’04.


 SELECT DISTINCT c.Cl_no, c.Name,so.D_dat FROM Client_sajid c JOIN
Salesorder_sajid so ON c.Cl_no = so.Cl_no WHERE so.O_dat < DATE '2004-06-04';

17. List all the clients who stays in “Bengaluru” or “Mangalore


 SELECT * FROM CLIENT WHERE CITY = 'Bangaluru' OR CITY = 'Mangalore';
Faculty of Engineering & Technology

Database Management System

(303105203) B.Tech CSE 2ndYear


3rdSemester

ENROLLMENT NO: 2303031250120

PRACTICAL: 10
Aim: “PL/SQL “ Block
1. Write a PL/SQL Block to Add 2 Numbers

DECLARE
a NUMBER(2);
b NUMBER(2);
c NUMBER(2);
BEGIN
a := 5; -- Replace with your desired value for 'a'
b := 10; -- Replace with your desired value for 'b'
c := a + b;
dbms_output.put_line(a || '+' || b || '=' || c);
END;
OUTPUT:

2. Write a PL/SQL Block to find Area of Rectangle, Triangle and Square.

DECLARE
length_val NUMBER := 5;
width_val NUMBER := 5;
height_val NUMBER := 5;
base_val NUMBER := 5; -
radius_val NUMBER := 5;
area1 NUMBER(10);
Faculty of Engineering & Technology

Database Management System

(303105203) B.Tech CSE 2ndYear


3rdSemester

area2 FLOAT(10); ENROLLMENT NO: 2303031250120

area3 FLOAT(10);
BEGIN
area1 := length_val * width_val;
area2 := base_val * height_val * 0.5;
area3 := 3.14 * radius_val * radius_val;
DBMS_OUTPUT.PUT_LINE('Area of rectangle is ' || length_val || ' * ' || width_val || ' = ' || area1);
DBMS_OUTPUT.PUT_LINE('Area of triangle is ' || base_val || ' * ' || height_val || ' * 0.5 = ' ||
area2);
DBMS_OUTPUT.PUT_LINE('Area of circle is ' || area3);
END;
OUTPUT:

3. Write a PL/SQL Block to find Maximum of 3 numbers.


DECLARE
a NUMBER(3) := 80;
b NUMBER(3) := 50;
c NUMBER(3) := 15;
BEGIN
IF a > b AND a > c THEN
DBMS_OUTPUT.PUT_LINE('Maximum number is : ' || a);
ELSIF b > a AND b > c THEN
DBMS_OUTPUT.PUT_LINE('Maximum number is : ' || b);
ELSE
DBMS_OUTPUT.PUT_LINE('Maximum number is : ' || c);
END IF;
Faculty of Engineering & Technology

Database Management System

(303105203) B.Tech CSE 2ndYear


3rdSemester

END; ENROLLMENT NO: 2303031250120


OUTPUT:

4. Write a PL/SQL Block to print sum of N Numbers using For Loop.


DECLARE
n NUMBER(5) := 55;
res NUMBER(5) := 0;
BEGIN
WHILE n > 0 LOOP
res := res + n;
n := n - 1;
EXIT WHEN n = 0;
END LOOP;
DBMS_OUTPUT.PUT_LINE('Sum is : ' || res);
END;
OUTPUT:

5. Write a PL/SQL Block to generate Fibonacci series of N numbers.


DECLARE
first_number NUMBER := 0;
second_number NUMBER := 1;
third_number NUMBER(5);
Faculty of Engineering & Technology

Database Management System

(303105203) B.Tech CSE 2ndYear


3rdSemester

n NUMBER := 5; ENROLLMENT NO: 2303031250120

i NUMBER(5);
BEGIN
DBMS_OUTPUT.PUT_LINE('Fibonacci series is : ');
DBMS_OUTPUT.PUT_LINE(first_number);
DBMS_OUTPUT.PUT_LINE(second_number);
FOR i IN 2 .. n LOOP
third_number := first_number + second_number;
first_number := second_number;
second_number := third_number;
DBMS_OUTPUT.PUT_LINE(third_number);
END LOOP;
END;
OUTPUT:

You might also like