Professional Documents
Culture Documents
Before Deletion:
After Deletion:
After Updating:
Sno varchar(2),
Name varchar(50),
Status number(10),
City varchar(10),
);
Describe supplier45;
INSERT INTO supplier45(Sno, Name, Status, City, PHONE) VALUES ('S1', 'JASON', 20,
'LONDON', 70);
INSERT INTO supplier45(Sno, Name, Status, City, PHONE) VALUES ('S2', 'ROY', 69, 'LONDON',
69);
INSERT INTO supplier45(Sno, Name, Status, City, PHONE) VALUES ('S3', 'HARDIK', 22,
'LONDON', 57);
Sno varchar(2),
Name varchar(50),
Status number(10),
City varchar(10),
);
Describe supplier045;
INSERT INTO supplier045(Sno, Name, Status, City, PHONE) VALUES ('S1', 'JASON', 20,
'LONDON', 70);
INSERT INTO supplier045(Sno, Name, Status, City, PHONE) VALUES ('S2', 'BISHOP', 20,
'MELBOURNE', 80);
INSERT INTO supplier045(Sno, Name, Status, City, PHONE) VALUES ('S3', 'SAINT', 10,
'BRISBANE', 90);
CREATE TABLE parts045
Pno varchar(2),
Weight number(3),
PHONE number(5),
);
Describe parts045;
ORIGINAL TABLE
Initial table
Grouped By Name:
19.To JOIN (INNER, LEFT, RIGHT, FULL) joins in oracle SQL.
CREATE TABLE supplier05
Sno varchar(2) ,
Name varchar(50),
Status number(10),
City varchar(10),
PHONE number(5)
);
Pno varchar(2),
PHONE number(5)
);
Describe parts05;
Describe supplier05;
INSERT INTO supplier05(Sno, Name, Status, City, PHONE) VALUES ('S1', 'JASON', 20, 'LONDON', 70);
INSERT INTO supplier05(Sno, Name, Status, City, PHONE) VALUES ('S2', 'ROY', 69, 'AUSTRALIA', 69);
INSERT INTO supplier05(Sno, Name, Status, City, PHONE) VALUES ('S3', 'HARDIK', 22, 'CANADA', 57);
INSERT INTO supplier05(Sno, Name, Status, City, PHONE) VALUES ('S4', 'LAKSHYA', 20, 'TOKYO', 55);
INSERT INTO supplier05(Sno, Name, Status, City, PHONE) VALUES ('S5', 'STATHAM', 40, 'BRISBANE', 12);
INSERT INTO supplier05(Sno, Name, Status, City, PHONE) VALUES ('S6', 'BISHOP', 45, 'AUCKLAND', 34);
INSERT INTO supplier05(Sno, Name, Status, City, PHONE) VALUES ('S7', 'MECHANIC', 70, 'DENVER', 44);
SUPPLIER TABLE
PARTS TABLE
INNER JOIN
SELECT parts05.Pno, supplier05.Name FROM supplier05
ON supplier05.PHONE = parts05.PHONE;
LEFT JOIN
SELECT parts05.Pno, supplier05.Name FROM supplier05
ON supplier05.PHONE = parts05.PHONE;
RIGHT JOIN
SELECT parts05.Pno, supplier05.Name FROM supplier05
ON supplier05.PHONE = parts05.PHONE;
FULL JOIN
SELECT parts05.Pno, supplier05.Name FROM supplier05
ON supplier05.PHONE = parts05.PHONE;
EXPERIMENT
Queries:
COURSE_NO COURSE_NAME
C101 O System
C102 Material Science
C103 Chemistry
C104 Automata
C105 DBMS
C106 JAVA PROGRAMMING
C107 Compilers
C108 Python
C109 Computer Graphics
C110 Computer Networks
create table Course_fee(course_no char(4) references Course(course_no),
full_part char(1) check (full_part='P' or full_part='F'), fees number(10));
D_
PROSPEC NA ADDR PHON O_ TOTAL AMT_ INSTAL
TUS_NO ME ESS E_NO B _AMT PAID LMENT
218053 Gane Delhi 999999 01- 20153 20153 F
sh 9999 AU
G-
00
218044 Gait Narnaul 888888 09- 32153 20153 I
onde 8888 MA
Y-
00
218002 Sarta Odisha 777777 12- 32673 32673 F
j 7777 SEP
-99
218060 Sing Kanpur 666666 03- 25543 25000 I
h 6666 JUL
-01
218045 Hard Yamun 555555 03- 19214 19214 F
ik anagar 5555 JU
N-
00
218004 Anki Patna 444444 27- 11328 11328 F
ta 4444 DE
C-
99
218038 Man Dehrad 333333 31- 11872 10000 I
as un 3333 OC
T-
00
218061 Dhru Uttrakh 222222 05- 21634 21634 F
v and 2222 OC
T-
00
218010 Deep Dehrad 888844 13- 16752 16750 I
ak un 4456 NO
V-
00
218057 Ansh Noida 227766 27- 12182 12182 F
u 3399 OC
T-
99
Executing Queries:
NAME COURSE_NO
Ganesh C101
Gaitonde C102
Sartaj C103
Singh C104
Hardik C105
Ankita C106
Manas C107
Dhruv C108
Deepak C109
Anshu C110
List the names of students who have paid the full amount at the time of
admission.
select name from Student where installment = 'F';
NAME
Ganesh
Sartaj
Hardik
Ankita
Dhruv
Anshu
NAME
Singh
Ankita
Anshu
Print the names of students whose total amount is not equal to amount
due.
select name from Student where total_amt<>(total_amt-amt_paid);
NAME
Ganesh
Gaitonde
Sartaj
Singh
Hardik
Ankita
Manas
Dhruv
Deepak
Anshu
Determine the maximum and minimum course fees.
select min(fees), max(fees) from Course_fee;
MIN(FEES) MAX(FEES)
11328 32673
Print the details of courses whose fees are between 15000 and 20000.
select Course.course_no, course_name, full_part from Course, Course_fee
where Course.course_no = Course_fee.course_no and fees between 15000 and
20000;
D_O_B
01-AUG-00
09-MAY-00
12-SEP-99
03-JUL-01
03-JUN-00
27-DEC-99
31-OCT-00
05-OCT-00
13-NOV-00
27-OCT-99
Change the course_name from JAVA to Core JAVA.
update course set course_name = 'Core JAVA' where course_name = 'JAVA';
1 row(s) updated.
Select the students who have not yet paid full amount of fees.
select Installment.prospectus_no, Student.name from Student, Installment where
Student.prospectus_no = Installment.prospectus_no and Installment.Paid = 'U';
PROSPECTUS_N NAM
O E
218044 Harshi
t
218038 Manas
EXPERIMENT
Queries:
Creating Tables and Inserting Data
create table Supplier (Sno char(3) primary key, Sname varchar(10), Status int,
City varchar(10));
insert into Supplier values ('S1','SRK',20,'Delhi');
insert into Supplier values ('S2','Selmon',55,'Noida');
insert into Supplier values ('S3','KRK',13,'Gurgoan');
insert into Supplier values ('S4','Udit',24,'Pune');
insert into Supplier values ('S5','Ramesh',42,'Mumbai');
insert into Supplier values ('S6','Amit',30,'Bhopal');
insert into Supplier values ('S7','Vikas',12,'Jaipur');
insert into Supplier values ('S8','Suraj',43,'Chennai');
insert into Supplier values ('S9','Shubh',32,'Bangalore');
insert into Supplier values ('S10','Paras',29,'Chandigarh');
select * from Supplier;
create table Parts (Pno char(3) primary key, Pname varchar(10), Color
varchar(10), Weight int, City varchar(10));
create table Project (Jno char(3) primary key, Jname varchar(10), City
varchar(20));
create table SPJ (Sno char(3) references Supplier(Sno), Pno char(3) references
Parts(Pno), Jno char(3) references Project(Jno), Qty int);
Executing Queries:
SNO
S1
Get sno values for suppliers who supply project j1 with part p1.
select sno from spj where jno = 'J1' and pno = 'P1';
SNO
S1
COLOR
Blue
PNO
P4
Get sno values for suppliers who supply project j1 with a blue part.
select Sno from SPJ, Parts where SPJ.Pno = Parts.Pno and Jno='J1' and
Color='Blue';
SNO
S1
Get sno values for suppliers who supply a Noida or Delhi project with a
red part.
select Sno from SPJ, Parts, Project where SPJ.Pno = Parts.Pno and SPJ.Jno =
Project.Jno and Parts.Color = 'Red' and (Project.City = 'Delhi' or Project.City =
'Noida');
SNO
S2
Get pno values for parts supplied to any project by a supplier in the same
city.
select Pno from SPJ, Project, Supplier where SPJ.Jno = Project.Jno and SPJ.Sno
= Supplier.Sno and Supplier.City = Project.City;
PNO
P1
P2
P3
P4
P5
P6
P7
P8
P9
P10
Get pno values for parts supplied to any project in Bhopal by a supplier in
Bhopal.
select Pno from SPJ, Project, Supplier where SPJ.Jno = Project.Jno and SPJ.Sno
= Supplier.Sno and Supplier.City = Project.City and Supplier.City = 'Bhopal';
PNO
P6
Get jnames for those project which are supplied by supplier Shubh.
select Jname from Project, SPJ, Supplier where SPJ.Jno = Project.Jno and
SPJ.Sno = Supplier.Sno and Supplier.Sname = 'Shubh';
JNAME
Exhibits
Get sname values for suppliers who supply to projects j1 and j2.
select Sname from Supplier, SPJ where SPJ.Sno = Supplier.Sno and (Jno='J1' or
Jno='J2');
SNAME
SRK
Selmon
PNO
P4
SUM(QTY)
200
COUNT(SNO)
1
SQL Code:-
Update employee
Set Com_value=70000
where eid=1001;
Update employee
Set Com_value=30000
where eid=1002;
Update employee
Set Com_value=60000
where eid=1003;
Update employee
Set Com_value=40000
where eid=1004;
Update employee
Set Com_value=50000
where eid=1005;
Update employee
Set Com_value=30000
where eid=1006;
select Lastname from employee where Lastname like '%a' and Lastname like
'%e';
SELECT Lastname,
Hiredate,TO_CHAR(NEXT_DAY(ADD_MONTHS(Hiredate,
6),'MONDAY'),'fmDay, "the" Ddspth "of" Month, YYYY') REVIEW FROM
employee;