Record
Record
STUDENT DETAILS DATABASE The student details database has a table with the following attributes.
STUDENT (RegNo: number; Name: text; DOB: date; Marks: number)
desc student1028;
• Remove the existing attribute marks from the table
Table altered.
desc student1028;
Table altered
desc student1028;
Table altered.
desc student1028;
1 row(s) inserted.
1 row(s) inserted.
1 row(s) inserted
1 row(s) inserted.
Order by regno
Result: Thus the above program was successfully completed and verified.
PROGRAM : 2.
LIBRARY DATABASE A library database has a table with the following attributes:LIBRARY (Bookld:
number; Title: text; Author: text; Publisher: text; Year_Pub: number; Price: number (6,2))
d) List details of all the books whose price ranges between Rs. 100.00 and Rs.300.00
Create table
Table created.
desc library1028;
1 row(s) inserted
1 row(s) inserted.
1 row(s) inserted.
1 row(s) inserted.
• List details of all the books whose price ranges between Rs. 100.00 and Rs.300.00
The salary database of an organization has a table ith the following attributes:
EMPSALARY (EmpCode: number; EmpName: text; DOB: date; Dept: text; Salary Number (10,2))
d) Find the sum and average of the salaries of employees of a particular department.
h) Increase the salary of those employees working for the accounts department by Rs. 1000.
i) Display all employees increasing order of their age for a specific department.
create table empsalary1028(empcode number(10) primary key, empname varchar2(20), dob date, dept
varchar2(20),salary number(10,2));
Table created.
1 row(s) inserted.
d) Find the sum and average of the salaries of employees of a particular department.
1 row(s) updated.
i) Display all employees increasing order of their age for a specific department.
PROGRAM 4:
INVENTORY DATABASE An inventory database has the following tables ITEM (ItemCode: number,
ItemName: text; Price: number (10,2)) PURCHASE (ItemCode: number, Quantity: number)
a) Create the tables with the above attributes.
d) Display the total items purchased (listing must have the columns: ItemCode ItemName,
TotalQuantity)
Table 1: item
Create table 2:
Table 2: purchase
desc purchase20cs1k1028;
d) Display the total items purchased (listing must have the columns: ItemCode ItemName, Total,
Quantity)
Create view
Item table:
. select itemname from item where itemcode not in (select itemcode from purchase);
PROGRAM :5
CUSTOMER (CustNo: number; CustName: text; City: text; AccNo: number; Balance: number (10,2))
ACCOUNT (AccNo: number; AccType: text; Branch: text; AccStatus: text; ChequeFacility: text
a) Create the above tables and specify the primary and foreign keys
d) List all the customers whose balance is greater than 30000.00 and have anactiveaccount.
e) Find the current outstanding balance amount of branch "Malleshwar"
a) Create the above tables and specify the primary and foreign keys
Create 2 Tables:
desc account1028;
Customer Table:
desc customer1028;
d) List all the customers whose balance is greater than 30000.00 and have anactiveaccount.
select custname from account,customer where accstatus='active' and balance >30000 and
account.accno=customer.accno;
e) Find the current outstanding balance amount of branch "Malleshwar"
Result:
Thus the above query was successfully fetch the data from bank customer database
Program 6
INSURANCE DATABASE
The primary keys are underlined and the data types are specified.
PARTICIPATED (DriverId; text; RegNo: text; ReportNo; number, Dmg_Amt:number (10, 2))
a) Create the above tables by specifying the primary and foreign keys.
b) Enter at least five tuples for each relation
e) Find the total number of people who owned cars that were involved in accidents in the year 2002.
f) Find the number of accidents in which cars belonging to a specific model were involved.
a) Create the above tables by specifying the primary and foreign keys.
desc person1028;
desc car1028;
desc owns1028;
desc accident1028;
-- PARTICIPATED (DriverId; text; RegNo: text; ReportNo; number, Dmg_Amt:number (1 0,2))
desc participated1028;
b) Enter at least five tuples for each relation Insert values into person table:
select count(*) from accident1028 where accdate between '01/01/2002' and '12/31/2002';
--f) Find the number of accidents in which cars belonging to a specific model were involved.
RESULT
Process finished
PROGRAM 7
ORDER PROCESSING DATABASE
Consider the following relations for an order processing database application in a company.
CUSTOMER (Custld: number, CustName: text; City: text)
CUSTORDER (OrderNo; number; OrderDate: date; Custld: number; OrderAmount: number) ITEM
(ItemNo: number, ItemName: text; UnitPrice number (10,2));
a) Create the above tables by properly specifying the primary keys and the foreign keys.
c) Produce a listing: CustName; no_of_orders; avg_order_amt; where the middle attribute is the
total average order amount for that customer.
d) List the order_no for orders that were shipped from all the warehouses that the company has
in a specific way
e) Demonstrate the delete of itemno 919 from the ITEM table and make that field null in the
ORDER_ITEM table.
desc customertable1028bca;
create table itemtable1028bca(itemno number(5) primary key, itemname char(10) not null,unitprice
number(10) not null);
desc itemtable1028bca;
create table custordertable1028bca(orderno number(5) primary key,orderdate date not null, custid
number(5) references customertable1028bca(custid),orderamount number(10,2) not null);
desc custordertable1028bca;
create table orderitemtable1028bca(orderno number(5) references
custordertable1028bca(orderno),itemno number(5) references itemtable1028bca(itemno) on delete
cascade,orderitemqty number(5) not null);
desc orderitemtable1028bca;
desc warehousetable1028bca;
desc shipmenttable1028bca;
RESULT
Process finished
PROGRAM 8
Create tables :
create table student1028bca(regno number(10) primary key, name varchar2(15)not null, major
varchar(10) not null, bdate date not null);
desc student1028bca;
desc course1028bca;
desc enroll1028bca;
desc textbook1028bca;
desc bookadoption1028bca;
b.Enter at least five tuples for each relation.
insert into student1028bca values(:regno,:name,:major,:bdate);
c. Insert a new text book to the database and make this book be adopted by some
department.
insert into textbook1028bca values(6005,'Java','albertz','prentice');
select * from textbook1028bca;
RESULT
Process finished
PROGRAM 9
MOVIE DATABASE
e)Find all the stars that appear in a movie made in 1980 or a movie with “life” in the title
RESULT
Process finished
PROGRAM 10
CREATE TABLES
create table student33(snum number(2) primary key,sname char(15) not null,major char(15) not
null,leve char(10) not null,age number(2));
desc student33;
create table faculty33(fid number(5) primary key,fname char(15) not null, deptid number(4) unique);
desc faculty33;
create table class33(cname char(15) primary key,meets_at varchar2(15) not null,room number(4) not
null,fid number(5) references faculty33(fid));
desc class33;
desc enrolled33;
c) select distinct (s.sname) from student33 s,class33 c,enrolled33 e,faculty33 f where s.snum=e.snum
and e.cname=c.cname and c.fid=f.fid and f.fname='Ram' and s.leve='JR';
e)select distinct s.sname from student10 s where s.snum in (select e1.snum from enrolled4 e1,enrolled4
e2,class10 c1, class10 c2 where e1.snum <> e2.snum and e1.cname <> e2.cname and
e1.cname=c1.cname and e2.cname=c2.cname and c1.meets_at=c2.meets_at);
g)select distinct f.fname from faculty33 f where 5 >(select count(e.snum) from class33 c,enrolled33 e
where c.cname=e.cname and c.fid=f.fid);
RESULT
Process finished
PROGRAM11
Write a program to multiply two numbers by prompting for values from the user. Then the result should
be displayed as “The multiplication of 5 and 10 is 50” (if 5 and 10 were supplied by the user)
declare
a number;
b number;
c number;
begin
a:=:a;
b:=:b;
c:=a*b;
end;
RESULT
STATEMENT PROCESSED
PROGRAM 12
Display the name, salary and job of the employee MARTIN of the emp table in the format MARTIN is
working as SALESMAN and earning a salary of 1250 using a PL/SQL block
desc emp1028bca;
vname varchar2(20);
vsal number;
vjob varchar2(10);
begin
end;
RESULT
STATEMENT PROCESSED
PROGRAM 13
Write a PL/SQL code to retrieve the employee name, join_date and designation from employee database
of an employee whose number is input by the user
desc employee33;
DECLARE
empnum number(8):=#
c_name employee.ename%type;
c_joindate employee.joindate%type;
c_designation employee.designation%type;
begin
END;
RESULT
STATEMENT PROCESSED