Practicle of Dbms
Practicle of Dbms
Roll No-130601
Assignment on DBMS(SQL/Oracle)
ASSIGNMENT-I
Create the table with given specification and constraints and insert about ten
rows.
1. Create table Colleges (cname, city, address, phone afdate) :SQL> create table Colleges(Cname varchar2(20) primary key,City varchar2(15),Address
varchar2(30),Phone varchar2(10),Afdate date);
Table Created.
SQL> insert into colleges (cname, city, address, phone, afdate) values ('Mahant
College','raipur','Gandhi Chowk','9302191167','01-FEB-91');
SQL> insert into colleges (cname, city, address, phone, afdate) values ('Disha
College','raipur','Ramnagar','9827998279','10-JAN-95');
SQL> insert into colleges (cname, city, address, phone, afdate) values ('Science
College','raipur','GE Road','0771223344','26-AUG-00');
SQL> insert into colleges (cname, city, address, phone, afdate) values ('SAI
college','Bhilai','Sector 6','0771323256','02-MAR-82');
SQL> insert into colleges (cname, city, address, phone, afdate) values ('Harishankar
college','raipur','Shankar Nagar','0771898999','01-JUL-90');
SQL> insert into colleges (cname, city, address, phone, afdate) values ('Central
College','raipur','Fafadih','9992299933','30-JUN-90');
SQL> insert into colleges (cname, city, address, phone, afdate) values ('Gurukul
College','raipur','Kalibadi Chowk','0771234567','12-JAN-96');
SQL> insert into colleges (cname, city, address, phone, afdate) values ('Vipra
College','raipur','Kota','9300290999','15-DEC-01');
SQL> insert into colleges (cname, city, address, phone, afdate) values ('Kalyan
College','Durg','Sector 7','9826106061','06-OCT-95');
SQL> insert into colleges (cname, city, address, phone, afdate) values ('MAIC
College','raipur','Samta Colony','9829900007','23-SEP-96');
Path: D/Anil/DBMS.docx
Page 1
Roll No-130601
Assignment on DBMS(SQL/Oracle)
2. Create table Staffs (sid, sname,saddress, contacts) :SQL> create table Staffs(sid varchar2(3) primary key,sname varchar2(15),saddress
varchar2(40),contacts varchar2(10));
Table Created.
SQL> insert into staffs(sid, sname,saddress, contacts) Values('M01','Sunil','Purani
basti','9907799077');
SQL> insert into staffs(sid, sname,saddress, contacts) Values('M02','Sanjay','Samta
Colony','9300193001');
SQL> insert into staffs(sid, sname, saddress, contacts) Values('M03', 'Naresh','Ramsagar
Para','9826198261');
SQL> insert into staffs(sid,sname, saddress, contacts) Values('M04', 'Pukesh','Chhattisgarh
Nagar','9825598255');
SQL> insert into staffs(sid, sname, saddress, contacts) Values('V01', 'Monish','Police
Line','9632196007');
Path: D/Anil/DBMS.docx
Page 2
Roll No-130601
Assignment on DBMS(SQL/Oracle)
Path: D/Anil/DBMS.docx
Page 3
Roll No-130601
Assignment on DBMS(SQL/Oracle)
3. Create table staffjoins (Sid, Cname, Dept, Doj, Post, Salary) :SQL> create table staffjoins(Sid varchar2(3) primary key,Cname varchar2(20),Dept
Varchar2(15),Doj date,Post Varchar2(20), Salary number(7,2));
Table Created.
SQL> insert into staffjoins(Sid, Cname, Dept, Doj, Post, Salary)values('M01','Mahant
college','Computer','01-jul-05','Professor',18000);
SQL> insert into staffjoins(Sid, Cname, Dept, Doj, Post, Salary)values('M02','Central
College','Maths','15-aug-09', 'Professor',15000);
SQL> insert into staffjoins(Sid, Cname, Dept, Doj, Post, Salary)values('M03','Mahant
College','Computer','23-jan-11','Professor',20000);
SQL> insert into staffjoins(Sid, Cname, Dept, Doj, Post, Salary)values('M04','Vipra
College','Commerce','17-feb-10','Lecturer',10000);
SQL> insert into staffjoins(Sid, Cname, Dept, Doj, Post, Salary)values('V01','Science
College','Physics','10-jul-08','Principal',25000);
SQL> insert into staffjoins(Sid, Cname, Dept, Doj, Post, Salary)values('V02','Disha
College','Computer','11-dec-05','Reader',22000);
SQL> insert into staffjoins(Sid, Cname, Dept, Doj, Post, Salary)values('V03','SAI
College','Commerce','01-jul-10','Lecturer',11000);
SQL> insert into staffjoins(Sid, Cname, Dept, Doj, Post, Salary)values('D01','Kalyan
College','Maths','09-mar-09','Reader',21500);
SQL> insert into staffjoins(Sid, Cname, Dept, Doj, Post, Salary)values('D02','MAIC
College','Chemistry','12-may-06','Professor',18700);
SQL> insert into staffjoins(Sid, Cname, Dept, Doj, Post, Salary)values('D03','Gurukul
College','Computer','02-sep-05','Lecturer',13500);
Path: D/Anil/DBMS.docx
Page 4
Roll No-130601
Assignment on DBMS(SQL/Oracle)
4. Create table Teachings (Sid, Class, PaperID, Fsession, Tsession) :SQL> create table Teachings(Sid varchar2(3) primary key,Class varchar2(20),PaperID
Varchar2(20),Fsession Varchar2(7), Tsession varchar2(7));
Table Created.
SQL> insert into Teachings (Sid, Class, PaperID, Fsession, Tsession)Values('M01','BCA I','BCA
101','2009-12','2011-12');
SQL> insert into Teachings (Sid, Class, PaperID, Fsession, Tsession)Values('M02','BCA II','BCA
205',
'2009-12','2011-12');
Path: D/Anil/DBMS.docx
Page 5
Roll No-130601
Assignment on DBMS(SQL/Oracle)
SQL> insert into Teachings (Sid, Class, PaperID, Fsession, Tsession)Values('V02','B. Com.
I','BCOM 105','2009-12','2011-12');
SQL> insert into Teachings (Sid, Class, PaperID, Fsession, Tsession)Values('V03','B. Com
II','BCOM 203','2009-12','2011-12');
SQL> insert into Teachings (Sid, Class, PaperID, Fsession, Tsession)Values('D01','B. Com
III','BCOM 301','2009-12','2011-12');
SQL> insert into Teachings (Sid, Class, PaperID, Fsession, Tsession)Values('D02','PGDCA
II','PGDCA202','2011','2011');
SQL> insert into Teachings (Sid, Class, PaperID, Fsession, Tsession)Values('D03','B. Sc. II','BSC
204','2009-12','2011-12');
OUTPUT :- SQL> select * from teachings;
Path: D/Anil/DBMS.docx
Page 6
Roll No-130601
Assignment on DBMS(SQL/Oracle)
5. Create table Subjects (paperID, subject, paperno, papername) :SQL> create table Subjects(PaperID varchar2 (20) Not Null,Subject varchar2 (15),Paperno
number(2),Papername varchar2(20));
Table Created.
SQL> insert into Subjects(paperID, subject, paperno, papername)Values ('BCA
101','Maths',1,'Integration');
SQL> insert into Subjects(paperID, subject, paperno, papername)Values ('BCA
205','Computer',5,'Networking');
SQL> insert into Subjects(paperID, subject, paperno, papername)Values ('BCA
303','Maths',3,'Discrete');
SQL> insert into Subjects(paperID, subject, paperno, papername)Values ('PGDCA
103','Computer',1,'DBMS');
SQL> insert into Subjects(paperID, subject, paperno, papername)Values ('BSC
110','Computer',1,'PC SOFT');
SQL> insert into Subjects(paperID, subject, paperno, papername)Values ('BCOM
105','Commerce',2,'Cost Accounting');
SQL> insert into Subjects(paperID, subject, paperno, papername)Values ('BCOM
203','Commece',3,'Management');
SQL> insert into Subjects(paperID, subject, paperno, papername)Values ('BCOM
301','Commerce',1,'Accounting');
SQL> insert into Subjects(paperID, subject, paperno, papername)Values
('PGDCA202','Computer',2,'Java');
SQL> insert into Subjects(paperID, subject, paperno, papername)Values ('BSC
204','Chemistry',2,'Physical Chemistry');
Path: D/Anil/DBMS.docx
Page 7
Roll No-130601
Assignment on DBMS(SQL/Oracle)
Path: D/Anil/DBMS.docx
Page 8
Roll No-130601
Assignment on DBMS(SQL/Oracle)
PART-I
A. List the name of the teachers teaching computer subjects.
SQL> select sname,dept from staffs,staffjoins
where staffs.sid=staffjoins.sid and staffjoins.dept='computer';
OUTPUT :-
B. List the name and cities of all staff working in your college
SQL> select sname,city from colleges,staffs,staffjoins
2 where colleges.cname=staffjoins.cname and
3 staffjoins.sid=staffs.sid and
4 colleges.cname='Mahant College';
OUTPUT :-
Path: D/Anil/DBMS.docx
Page 9
Roll No-130601
Assignment on DBMS(SQL/Oracle)
C. List the name and cities of all staffs working in your college who earn more than 15000.
SQL> sname,city,salary from select colleges,staffs,staffjoins
2 where colleges.cname=staffjoins.cname and staffjoins.sid=staffs.sid and
colleges.cname='Mahant
College' and staffjoins.salary>=15000;
OUTPUT :-
D. Find the staffs whose names start with M or R and ends with A and/or 7 characters
long.
SQL> select sname from staffs
2 where ((sname like 'M%' or sname like 'R%') and sname like '%A')or length(sname)='6';
OUTPUT :-
Path: D/Anil/DBMS.docx
Page 10
Roll No-130601
Assignment on DBMS(SQL/Oracle)
Path: D/Anil/DBMS.docx
Page 11
Roll No-130601
Assignment on DBMS(SQL/Oracle)
Path: D/Anil/DBMS.docx
Page 12
Roll No-130601
Assignment on DBMS(SQL/Oracle)
PART-II
A. Find the colleges who have most number of staff.
SQL> select cname,count(sid)from staffjoins group by cname
2 having count(sid) >=(select max (count(sid))from staffjoins group by cname);
OUTPUT :-
B. Find the staffs that earn a higher salary who earn greater than average salary of their
college..
SQL> select sname from staffs,staffjoins
2 where staffs.sid=staffjoins.sid and salary=(select max(salary) from staffjoins
3 where salary>(select avg(salary) from staffjoins));
OUTPUT :-
C. Find the colleges whose average salary is more than average salary of C2.
Path: D/Anil/DBMS.docx
Page 13
Roll No-130601
Assignment on DBMS(SQL/Oracle)
College');
OUTPUT :-
Path: D/Anil/DBMS.docx
Page 14
Roll No-130601
Assignment on DBMS(SQL/Oracle)
E. Find the college where the total salary is greater than is average salary of all colleges.
SQL> select cname, sum (salary) from staffjoins group by cname
2 having sum(salary)>(select avg(salary) from staffjoins);
OUTPUT :-
Path: D/Anil/DBMS.docx
Page 15
Roll No-130601
Assignment on DBMS(SQL/Oracle)
PART-III
A. List the name of teachers, departments teachings in more than one department.
SQL> select sname,dept from staffs, staffjoins where
2 dept='Computer' and dept='Physics' or
3 dept='Maths' and dept='Commerce' or
4 dept='Computer' and dept='Maths' or
5 dept='Computer' and dept='Commerce' or
6 dept='Physics' and dept='Maths' or
7 dept='Physics' and dept='Commerce';
OUTPUT :-
Path: D/Anil/DBMS.docx
Page 16
Roll No-130601
Assignment on DBMS(SQL/Oracle)
Path: D/Anil/DBMS.docx
Page 17
Roll No-130601
Assignment on DBMS(SQL/Oracle)
D. Find the name of staff that earn more than each staff of C2 college.
SQL> select cname,avg(salary)from staffjoins group by cname;
OUTPUT :-
Path: D/Anil/DBMS.docx
Page 18
Roll No-130601
Assignment on DBMS(SQL/Oracle)
PART-IV
A. Create a view having fields sname, ename, dept, doj, and post.
SQL> create view val as select
staffs.sname,colleges.cname,staffjoins.dept,staffjoins.doj,staffjoins
.post from colleges,staffs,staffjoins
2 where colleges.cname=staffjoins.cname and staffs.sid=staffjoins.sid;
OUTPUT :-
Path: D/Anil/DBMS.docx
Page 19
Roll No-130601
Assignment on DBMS(SQL/Oracle)
B. Create a view consisting of cname,average salary and total salary of all staff in that college.
SQL> create view vb1 as select cname,avg(salary)"average", sum(salary)"total" from staffjoins
group by cname;
OUTPUT :-
Path: D/Anil/DBMS.docx
Page 20
Roll No-130601
Assignment on DBMS(SQL/Oracle)
ASSIGNMENT-II
Create the table with given specification and constraints and insert about ten
rows.
1.
Create table Enrollment (enrollno, name, gender, dob, address, phone) :SQL> create table Enrollment(enrollno varchar2(7)primary key,name varchar2(15),gender
varchar2(1),dob date,address varchar2(20),phone varchar2(10));
Table Created.
SQL> insert into Enrollment(enrollno, name, gender, dob, address, phone) values('WW-1234',
'ANIL', 'M', '20-JAN-85', 'AVANTI VIHAR', '9827998279');
SQL> insert into Enrollment(enrollno, name, gender, dob, address, phone) values('WW1235','Priya','F','14-dec-84','Civil Lines','9999955555');
SQL> insert into Enrollment(enrollno, name, gender, dob, address, phone) values('WW1236','Swati','F','21-feb-86','VIP State','9898989898');
SQL> insert into Enrollment(enrollno, name, gender, dob, address, phone) values('WW1237','Mahendra','M', '02-apr-85','Ramnagar','9555555555');
SQL> insert into Enrollment(enrollno, name, gender, dob, address, phone) values('WW1238','Aditi','F','09-may-86','Avni Vihar','9797979797');
SQL> insert into Enrollment(enrollno, name, gender, dob, address, phone) values('WW1239','Raman','M','29-jul-85', 'Balaji Vihar','9292929292');
SQL> insert into Enrollment(enrollno, name, gender, dob, address, phone) values('WW1240','Neha','F','30-nov-86','Kabir Nagar','9300000000');
SQL> insert into Enrollment(enrollno, name, gender, dob, address, phone) values('WW1241','Prakash','M','22-mar-85','SBI Colony', '9988998899');
SQL> insert into Enrollment(enrollno, name, gender, dob, address, phone) values('WW1242','Rameshwar','M','17-oct-86','IT Colony','9698949695');
SQL> insert into Enrollment(enrollno, name, gender, dob, address, phone) values('WW1243','Vijay','M','11-aug-87', 'WRS Colony', '9494949494');
Path: D/Anil/DBMS.docx
Page 21
Roll No-130601
Assignment on DBMS(SQL/Oracle)
2.
Create table Admission (admno, Enrollno, Course, YearSem, Adate, cname) :SQL> create table Admission(admno number(3)Primary key,Enrollno varchar2(7),Course
varchar2(10),YearSem number(1),adate date,cname varchar2(20));
Table Created.
SQL> insert into Admission (admno, Enrollno, Course, YearSem, Adate, cname) values(1,'ww1234', 'BCA', 1, '10-JUL-12', 'Mahant College');
SQL> insert into Admission (admno, Enrollno, Course, YearSem, Adate, cname) values(2,'ww1235','BCA',2,'11-JUL-12','Central College');
SQL> insert into Admission (admno, Enrollno, Course, YearSem, Adate, cname) values(3,'ww1236','PGDCA',1,'02-JUL-12','Mahant College');
SQL> insert into Admission (admno, Enrollno, Course, YearSem, Adate, cname) values(4,'ww1237','MCA',1,'26-JUL-12','Disha College');
SQL> insert into Admission (admno, Enrollno, Course, YearSem, Adate, cname) values(5,'ww1238','DCA',1,'09-JUL-12','Vipra College');
Path: D/Anil/DBMS.docx
Page 22
Roll No-130601
Assignment on DBMS(SQL/Oracle)
SQL> insert into Admission (admno, Enrollno, Course, YearSem, Adate, cname) values(6,'ww1239','MCA',3,'16-JUL-12','Disha College');
SQL> insert into Admission (admno, Enrollno, Course, YearSem, Adate, cname) values(7,'ww1240','DCA',1,'15-JUL-12','Central College');
SQL> insert into Admission (admno, Enrollno, Course, YearSem, Adate, cname) values(8,'ww1241','PGDCA',1,'22-JUL-12','Mahant College');
SQL> insert into Admission (admno, Enrollno, Course, YearSem, Adate, cname) values(9,'ww1242','BCA',3,'23-JUL-12','Mahant College');
SQL> insert into Admission (admno, Enrollno, Course, YearSem, Adate, cname) values(10,'ww1243','MBA',1,'04-JUL-12','Disha College');
OUTPUT :- SQL> select * from admission;
Path: D/Anil/DBMS.docx
Page 23
Roll No-130601
Assignment on DBMS(SQL/Oracle)
3. Create table FeeStructure (Course,YearSem, Fee) :SQL> create table FeeStructure(Course Varchar2(10),YearSem number(1),Fee
Number(7,2));
Table Created.
SQL> insert into FeeStructure(Course,YearSem, Fee) values('PGDCA',1,18000);
SQL> insert into FeeStructure(Course,YearSem, Fee) values('BCA',1,15000);
SQL> insert into FeeStructure(Course,YearSem, Fee) values('BCA',2,14000);
SQL> insert into FeeStructure(Course,YearSem, Fee) values('BCA',3,12000);
SQL> insert into FeeStructure(Course,YearSem, Fee) values('MCA',1,25000);
SQL> insert into FeeStructure(Course,YearSem, Fee) values('MCA',2,22000);
SQL> insert into FeeStructure(Course,YearSem, Fee) values('MCA',3,20000);
SQL> insert into FeeStructure(Course,YearSem, Fee) values('DCA',1,15000);
SQL> insert into FeeStructure(Course,YearSem, Fee) values('MBA',1,30000);
SQL> insert into FeeStructure(Course,YearSem, Fee) values('MBA',2,25000);
OUTPUT :- SQL> select * from feestructure;
Path: D/Anil/DBMS.docx
Page 24
Roll No-130601
Assignment on DBMS(SQL/Oracle)
4. Create table Payment (billno, admno, amount, pdate,purpose) :SQL> create table Payment(billno number(3)primary key, Admno number(3),Amount
number(7,2), pdate date, purpose varchar2(15));
Table Created.
SQL> insert into Payment(billno, admno, amount, pdate,purpose) values(101,1,10000,'10-JUL12', 'Admission');
SQL> insert into Payment(billno, admno, amount, pdate,purpose) values(102,2,12000,'11-JUL12',' Admission');
SQL> insert into Payment(billno, admno, amount, pdate,purpose) values(103,3,11000,'02-JUL12',' Admission');
SQL> insert into Payment(billno, admno, amount, pdate,purpose) values(104,4,12000,'26-JUL12','Hostel');
SQL> insert into Payment(billno, admno, amount, pdate,purpose) values(105,5,15000,'09-JUL12','Admission');
SQL> insert into Payment(billno, admno, amount, pdate,purpose) values(106,6,20000,'16-JUL12','Admission');
SQL> insert into Payment(billno, admno, amount, pdate,purpose) values(107,7,12000,'15-JUL12','Hostel');
SQL> insert into Payment(billno, admno, amount, pdate,purpose) values(108,8,8000,'22-JUL12','Admission');
SQL> insert into Payment(billno, admno, amount, pdate,purpose) values(109,9,13000,'23-JUL12','Admission');
SQL> insert into Payment(billno, admno, amount, pdate,purpose) values(110,10,20000,'04-JUL12','Admission');
Path: D/Anil/DBMS.docx
Page 25
Roll No-130601
Assignment on DBMS(SQL/Oracle)
Path: D/Anil/DBMS.docx
Page 26
Roll No-130601
Assignment on DBMS(SQL/Oracle)
PART-I
A. Get full detail of all student who took admission this year class wise.
SQL> select enrollment.enrollno,name,gender,dob,address,phone,course from
enrollment,admission
2 where enrollment.enrollno=admission.enrollno and
3 to_date(admission.adate,'dd-mm-yy')>'01-jul-12' and
4 to_date(admission.adate,'dd-mm-yy')<'31-jul-12';
OUTPUT :-
Path: D/Anil/DBMS.docx
Page 27
Roll No-130601
Assignment on DBMS(SQL/Oracle)
Path: D/Anil/DBMS.docx
Page 28
Roll No-130601
Assignment on DBMS(SQL/Oracle)
2. By each college.
SQL> select cname,sum(fee) from feestructure,admission
2 where feestructure.course=admission.course group by cname;
OUTPUT :-
Path: D/Anil/DBMS.docx
Page 29
Roll No-130601
Assignment on DBMS(SQL/Oracle)
3. By all college.
SQL> select sum(fee) "sum" from feestructure;
OUTPUT :-
Path: D/Anil/DBMS.docx
Page 30
Roll No-130601
Assignment on DBMS(SQL/Oracle)
PART-II
A. List the students who have not payed full fee in your college.
SQL> select name,amount,course from enrollment,admission,payment
2 where enrollment.enrollno=admission.enrollno and
3 admission.admno=payment.admno and
4 cname='Mahant College' and amount<13000;
OUTPUT :-
Path: D/Anil/DBMS.docx
Page 31
Roll No-130601
Assignment on DBMS(SQL/Oracle)
B. List the students in colleges in your city and also live in your city.
SQL> select name from enrollment,admission,colleges
2 where enrollment.enrollno=admission.enrollno and
3 admission.cname=colleges.cname and
4 colleges.city='Raipur';
OUTPUT :-
Path: D/Anil/DBMS.docx
Page 32
Roll No-130601
Assignment on DBMS(SQL/Oracle)
ASSIGNMENT-III
Create the table with given specification and constraints and insert about ten
rows.
1. Create table Test (paperid, tdate, time, max, min) :SQL> create table Test (PaperID Varchar2(10)primary key, Tdate date, Time Varchar2(7),
Max number(3), Min number(2));
Table Created.
SQL> insert into Test(paperid, tdate, time, max, min) values('BCA101', '01-NOV-12', '10:00AM',
50,60);
SQL> insert into Test(paperid, tdate, time, max, min)values('BCA102','02NOV12','10:00AM',
100,40);
SQL> insert into Test(paperid, tdate, time, max, min) values('BCA201','03-NOV-12','10:00AM',
150,60);
SQL> insert into Test(paperid, tdate, time, max, min) values('BCA306','05-NOV-12','10:00AM',
50,20);
SQL> insert into Test(paperid, tdate, time, max, min) values('PGDCA101','05-NOV-12',
'02:00PM, 100,20);
SQL> insert into Test(paperid, tdate, time, max, min) values('DCA101','06-NOV-12','02:00PM',
100,20);
SQL> insert into Test(paperid, tdate, time, max, min) values('MCA02','07-NOV-12','02:00PM',
100,40);
SQL> insert into Test(paperid, tdate, time, max, min) values('MBA10','08-NOV-12','10:00AM',
100,40);
SQL> insert into Test(paperid, tdate, time, max, min) values('MCA09','09-NOV-12','02:00PM',
50,20);
SQL> insert into Test(paperid, tdate, time, max, min) values('PGDCA103','10-NOV-12',
'02:00PM', 100,20);
Path: D/Anil/DBMS.docx
Page 33
Roll No-130601
Assignment on DBMS(SQL/Oracle)
2.
Create table score (rollno, paperID, marks, attendence) :SQL> create table score (rollno number(4)primary key, paperid varchar2(10), Marks
number(3), Attendence number (3));
Table Created.
SQL> insert into score(rollno, paperID, marks, attendence) values(1001,'BCA101', 80,65);
SQL> insert into score(rollno, paperID, marks, attendence) values(1002,'BCA102',60,67);
SQL> insert into score(rollno, paperID, marks, attendence) values(2001,'BCA201',88,85);
SQL> insert into score(rollno, paperID, marks, attendence) values(2002,'BCA201',91,75);
SQL> insert into score(rollno, paperID, marks, attendence) values(3001,'PGDCA101',45,74);
SQL> insert into score(rollno, paperID, marks, attendence) values(4001,'DCA101',66,63);
SQL> insert into score(rollno, paperID, marks, attendence) values(5001,'MCA02',88,50);
SQL> insert into score(rollno, paperID, marks, attendence) values(6001,'MBA10',56,74);
SQL> insert into score(rollno, paperID, marks, attendence) values(5002,'MCA09',55,85);
SQL> insert into score(rollno, paperID, marks, attendence) values(3002,'PGDCA103',60,91);
OUTPUT :- select * from score;
Path: D/Anil/DBMS.docx
Page 34
Roll No-130601
Assignment on DBMS(SQL/Oracle)
3. Create table score 1 (rollno, paperID, marks, attendence) :SQL> Create Table Score(rollno number(4)primary key, paperid varchar2(10), Marks
number(3), Attendence varchar2(20));
Table Created.
SQL> insert into score1(rollno, paperID, marks, attendence) values(1001, 'BCA101', 80,P);
SQL> insert into score1(rollno, paperID, marks, attendence)values(1002,'BCA102',60,P);
SQL> insert into score1(rollno, paperID, marks, attendence)values(2001,'BCA201',88,P);
SQL> insert into score1(rollno, paperID, marks, attendence)values(2002,'BCA201',91,P);
SQL> insert into score1(rollno, paperID, marks, attendence)values (3001,'PGDCA101',45,P);
SQL> insert into score1(rollno, paperID, marks, attendence)values(4001,'DCA101',66,P);
Path: D/Anil/DBMS.docx
Page 35
Roll No-130601
Assignment on DBMS(SQL/Oracle)
Path: D/Anil/DBMS.docx
Page 36
Roll No-130601
Assignment on DBMS(SQL/Oracle)
4. Create table students (Admno, Rollno, Class, Yearsem) :SQL> Create Table Students (Admno Number(3), Rollno Number(4), Class Varchar2(10),
Yearsem Number(1));
Table Created.
SQL> Insert Into Students (Admno, Rollno, Class, Yearsem) Values(1, 1001, 'BCA', 1);
SQL> Insert Into Students (Admno, Rollno, Class, Yearsem) Values(2,2001,'BCA', 2);
SQL> Insert Into Students (Admno, Rollno, Class, Yearsem) Values(3,3001, 'PGDCA',1);
SQL> Insert Into Students (Admno, Rollno, Class, Yearsem) Values(4,5001,'MCA', 1);
SQL> Insert Into Students (Admno, Rollno, Class, Yearsem) Values(5,4001,'DCA', 1);
SQL> Insert Into Students (Admno, Rollno, Class, Yearsem) Values(6,5302,'MCA', 3);
SQL> Insert Into Students (Admno, Rollno, Class, Yearsem) Values(7,4002,'DCA', 1);
SQL> Insert Into Students (Admno, Rollno,Class,Yearsem)Values(8,3002,'PGDCA',1);
SQL> Insert Into Students (Admno, Rollno, Class, Yearsem) Values(9,2050,'BCA', 3);
SQL> Insert Into Students (Admno, Rollno, Class, Yearsem)Values(10,6001,'MBA', 1);
OUTPUT :- SQL> select * from students;
Path: D/Anil/DBMS.docx
Page 37
Roll No-130601
Assignment on DBMS(SQL/Oracle)
Path: D/Anil/DBMS.docx
Page 38
Roll No-130601
Assignment on DBMS(SQL/Oracle)
C. List all students in PGDCA-II who have score higher than average in your college.
SQL> select score.rollno from score,students
2 where score.rollno=students.rollno and
3 marks>(select avg(marks) from score
4 where class='PGDCA');
OUTPUT :-
D. List all students in BCA-II who have scored higher than average in every college.
SQL> select score.rollno from score,students
2 where score.rollno=students.rollno and
3 marks>(select avg(marks) from score
4 where class='BCA');
OUTPUT :-
Path: D/Anil/DBMS.docx
Page 39
Roll No-130601
Assignment on DBMS(SQL/Oracle)
E. List the highest score average and minimum score in BCA in your college.
SQL> select avg(marks),min(marks)from score,students,admission
2 where score.rollno=students.rollno and class='BCA' and cname='Mahant College';
OUTPUT :-
F. List the highest score average and minimum score in BCA in every college.
SQL> select avg(marks),min(marks)from score,students,admission
2 where score.rollno=students.rollno and class='BCA';
OUTPUT :-
Path: D/Anil/DBMS.docx
Page 40