Вы находитесь на странице: 1из 99

EX.

NO:
DATE:
QUESTION:
ABC University is a large institution with several campuses. Each campus has a different name,
address, distance to the city center and the only bus running to the campus. Each campus has one
club. The name of the club, the building in which the club is located, the phone number of the
club and the multiple sports which club offers, should all be
recorded.
The University consists of a number of faculties, such as the Art Faculty, the cience Faculty,
and so on. Each faculty has a name, dean and building. A faculty may be divided into a number
of schools, for e!ample, the cience Faculty has a chool of "hysics and a chool of Chemistry.
Each school belongs to one faculty only and is located on #ust one campus, but one campus
maybe the location of many schools. Every school has name and an building assigned to. Each
school offers different programmes and each programme can
be offered by only one school. Each programme has a uni$ue code, title, level and duration. Each
programme comprises several courses, different programmes have different courses. Each course
has a uni$ue code and course title. ome courses may have one or more prere$uisite courses and
one course can be the prere$uisite course of some other courses.
Each of the students is enrolled in a single programme of study which involves a fi!ed core of
courses specific to that programme as well as a number of electives ta%en from other
programmes. tudents wor% on courses and are awarded a grade in any course if he&she passes
the course. 'therwise the student has to re(ta%e the failed course. The system needs to record the
year and term in which the course was ta%en and the grade awarded to the student. Every student
has a uni$ue )*. The system also %eeps the student
name, birthday and the year he&she enrolled in the course.
The school employs lecturers to teach the students. A lecturer is allowed to wor% for one school
only. Each lecturer is assigned an )* which is uni$ue across the whole university. The system
%eeps the lecturer+s name, title and the office room. A supervisor maybe in charge of several
lecturers, but a lecturer, however reports to only one supervisor. A lecturer can teach many
different courses. A course may also have been taught by many different lecturers.
The university is operated by committees. Each faculty has to have a number of committees with
the same titles across the university, such as the Faculty E!ecutive, the "ost ,raduate tudies
Committee, the -ealth and anity Committee, and so on. The committees meet regularly, such as
wee%ly or monthly. The fre$uency is determined by the faculty involved. A committee+s
members are all lecturers. A lecturer may be a member of several committees.
AIM:
To create a database for University ystem )nformal *escription.
DESCRIPTION:
The *ata *efinition .anguage is used to create an ob#ect/e.g table0,alter the structure
of the table and also drop the ob#ect created. A table is a unit of storage that holds the data in
the form of rows and columns.
The *ata *efinition .anguage is used to
Create the table,
Alter the table,
Truncate the table,
*rop the table.
The *ata manipulation .anguage is used to insert an ob#ect,select is used to display fields and
delete to remove ob#ects inserted. A table is a unit of storage that holds the data in the form of
rows and columns.
The *ata manipulation .anguage is used to
)nsert
elect
Update
delete
QUERY:
create table university/uni1namevarchar/230 primary %ey,no1campus number/40,place
varchar/53006
Table created.
ynta!7
*esc table name6
8uery7
desc university6
OUTPUT:
Table Column Data Type Lent! P"e#$ %$ on S#al e P"$ ma"y &ey Nul labl e De'ault Comment
U9):E;)
T<
U9)19A=E :archar5 23 ( ( 2 ( ( (
9'1CA="U 9umber ( 4 3 ( ( (
".ACE :archar5 53 ( ( ( ( (
insert into university values/>panimalar>,22,>chennai>06
2 row/s0 inserted.
select ? from university6
OUTPUT:
UNI(NAME NO(CAMPUS PLACE
"animalar 22 Chennai
create table camp/uni1namevarchar/2@0 references
university,campus1namevarchar/2@0,cam1addrsvarchar/53006
Table created.
*escription7
ynta!7
*esc table1name6
desc camp6
OUTPUT:
Table Col umn Data Type Lent! P"e#$%$on S#ale P"$ ma"y &ey Null able De'aul t Comment
CA=" U9)19A=E :archar5 2@ ( ( ( ( (

CA="U19A=
E
:archar5 2@ ( ( ( ( (
CA=1A**; :archar5 53 ( ( ( ( (
ALTERATION:
Alter table camp add/camp1clubnamevarchar/2@0 primary %ey06
Table altered.
*escription7
ynta!7
*esc table1name6
ynta!7
*esc camp6
OUTPUT:
Tabl
e Col umn Data Type Lent! P"e#$ %$ on S#al e P"$ma"y &ey Nul labl e De'ault Comment
CA=
"
U9)19A=E :archar5 2@ ( ( ( ( (
CA="U19A=E :archar5 2@ ( ( ( ( (
CA=1A**; :archar5 53 ( ( ( ( (

CA="1C.UB9A=
E
:archar5 2@ ( ( 2 ( ( (
INSERTION:
)nsert into table 1name values)/a list of data values06
8uery7
insert into camp values/>panimalar>,>%it>,>chennai>,>sports1club>06
2 row/s0 inserted.
select ? from camp6
OUTPUT:
CREATION:
Create table clubname/camp1clubnamevarchar/2@0 references
camp,name1of1buildvarchar/530,phone1no number/2@0,sports varchar/53006
Table created.
*escription7
ynta!7
*esc table1name6
UNI(NAME CAMPUS(NAME CAM(ADDRS CAMP(CLU)NAME
"animalar %it chennai sports1club
ynta!7
*esc clubname6
OUTPUT:
Tabl e Col umn Data Type Lent! P"e#$ %$ on S#al e P"$ ma"y &ey Nul l abl e De'aul t Comment
C.UB9A=
E
CA="1C.UB9A=
E
:archar5 2@ ( ( ( ( (
9A=E1'F1BU).* :archar5 53 ( ( ( ( (
"-'9E19' 9umber ( 2@ 3 ( ( (
"';T :archar5 53 ( ( ( ( (
INSERTION:
)nsert into clubname values/>sports1club>,>f.c>,>A4BCDEA525>,>football>06
2 row/s0 inserted.
elect ? from clubname6
OUTPUT:
CAMP(CLU)NAME NAME(O*()UILD P+ONE(NO SPORTS
sports1club f.c A4BCDEA525 football
CREATION:
create table faculty
/fac1deptvarchar/230,fac1namevarchar/2@0,fac1deanvarchar/2@0,fac1buildingvarchar/2@0,fac1sch
l1namevarchar/2@0 primary %ey06

Table created.
*escription7
ynta!7
*esc table1name6
ynta!7
*esc faculty6
OUTPUT:
Table Col umn Data Type Lent! P"e#$%$on S#ale
P"$ ma"y
&ey Nul labl e De'ault Comment
FACU.T
<
FAC1*E"T :archar5 23 ( ( ( ( (
FAC19A=E :archar5 2@ ( ( ( ( (
FAC1*EA9 :archar5 2@ ( ( ( ( (
FAC1BU).*)9, :archar5 2@ ( ( ( ( (

FAC1C-''.19A
=E
:archar5 2@ ( ( 2 ( ( (
ALTERATION:
Alter table Ftable 1nameGadd/column2 definition2H.06
ynta!7
alter table faculty add/uni1namevarchar/530 references university06
Table altered.
*escription7
*esc table1name6
ynta!7
desc faculty6
OUTPUT:
Tabl e Column Data Type Lent! P"e#$ %$ on S#ale P"$ ma"y &ey Nul labl e De'ault Comment
FACU.
T<
FAC1*E"T :archar5 23 ( ( ( ( (
FAC19A=E :archar5 2@ ( ( ( ( (
FAC1*EA9 :archar5 2@ ( ( ( ( (
FAC1BU).*)9, :archar5 2@ ( ( ( ( (

FAC1C-''.19A
=E
:archar5 2@ ( ( 2 ( ( (
U9)19A=E :archar5 53 ( ( ( ( (
INSERTION:
)nsert into table 1name values)/a list of data values06
8uery7
insert into faculty values/>science>,>srimathi>,>mani>,>chemistry>,>scl1chemistry>,>panimalar>06
2 row/s0 inserted.
insert into faculty values/>science>,>%iruthi%a>,>tamil>,>physics>,>scl1physics>,>panimalar>06
2 row/s0 inserted.
insert into faculty values/>eng>,>simbu>,>%avin>,>cse>,>scl1cse>,>panimalar>06
2 row/s0 inserted.
elect ?from faculty6
OUTPUT:
*AC(DEPT *AC(NAME *AC(DEAN *AC()UILDIN, *AC(SC+OOL(NAME UNI(NAME
cience srimathi =ani chemistry scl1chemistry panimalar
cience %iruthi%a Tamil physics scl1physics panimalar
Eng imbu Iavin cse scl1cse panimalar
CREATION:
create table school/school1namevarchar/2@0 references faculty,pgm1code number/@0 primary
%ey,pgm1namevarchar/530,pgm1levelvarchar/2@0,pgm1dur number/23006
Table created.
insert into school values/>scl1chemistry>,>25>,>c>,>medium>,>B>06
2 row/s0 inserted.
insert into school values/>scl1cse>,>@D>,>dbms>,>high>,>@>06
2 row/s0 inserted.
insert into school values/>scl1physics>,>4>,>#ava>,>high>,>A>06
2 row/s0 inserted.
select ?from school6
OUTPUT:
SC+OOL(NAME P,M(CODE P,M(NAME P,M(LE-EL P,M(DUR
scl1chemistry 25 C medium B
scl1cse @D *bms high @
scl1physics 4 Java high A
CREATION:
create table student/pgm1code number/230 references school,gradevarchar/@0,std1id number/230
primary %ey,crossed1yeardate,std1namevarchar/530,std1#oining date06
Table created.
INSERTION:
insert into student values/>25>,>s>,45,>B(nov(532D>,>%iruthi%a>,>2(#uly(5322>06
2 row/s0 inserted.
insert into student values/>@D>,>B>,55,>4(#an(532D>,>vino>,>2(feb(5322>06
2 row/s0 inserted.
insert into student values/>4>,>A>,53,>4(feb(532D>,>%avi>,>2(mar(5322>06
2 row/s0 inserted.
select ?from student6
OUTPUT:
P,M(CODE ,RADE STD(ID CROSSED(YEAR STD(NAME STD(.OININ,
25 45 3B(9':(2D %iruthi%a 32(JU.(22
@D B 55 34(JA9(2D vino 32(FEB(22
4 A 53 34(FEB(2D %avi 32(=A;(22
CREATION:
create table lecture/std1id number/@0,lec1namevarchar/2@0,lec1id
number/230,pgm1namevarchar/530,supr1namevarchar/53006
Table created.
desc lecture6
OUTPUT:
Tabl e Col umn Data Type Lent! P"e#$ %$ on S#al e P"$ ma"y &ey Nul l abl e De' aul t Comment
.ECTU;E T*1)* 9umber ( @ 3 ( ( (
.EC19A=E :archar5 2@ ( ( ( ( (
.EC1)* 9umber ( 23 3 ( ( (
",=19A=E :archar5 53 ( ( ( ( (
U";19A=E :archar5 53 ( ( ( ( (
INSERTION:
insert into lecture values/25,>priya>,55,>dbms>,>dhivya>06
2 row/s0 inserted.
insert into lecture values/24,>bhuvana>,5@,>ds>,>sindhu>06
2 row/s0 inserted.
select ?from lecture6
OUTPUT:
STD(ID LEC(NAME LEC(ID P,M(NAME SUPR(NAME
25 "riya 55 dbms dhivya
24 Bhuvana 5@ ds sindhu
CREATION:
create table commitee/uni1namevarchar/2@0 references university,f1school1namevarchar/530
references faculty,commitee1namevarchar/43006
Table created.
*escription7
*esc table1name6
ynta!7
desccommitee6
OUTPUT:
Table Col umn Data Type Lent! P"e#$ %$ on S#ale P"$ma"y &ey Null able De'ault Comment
C'==)T
EE
U9)19A=E :archar5 2@ ( ( ( ( (

F1C-''.19A=
E
:archar5 53 ( ( ( ( (

C'==)TEE19A=
E
:archar5 43 ( ( ( ( (
INSERTION:
insert into commitee values/>panimalar>,>scl1physics>,>upper1graduate>06
2 row/s0 inserted.
insert into commitee values/>panimalar>,>scl1cse>,>post1graduate>06
2 row/s0 inserted.
select ?from commitee6
OUTPUT:
UNI(NAME *(SC+OOL(NAME COMMITEE(NAME
"animalar scl1physics upper1graduate
"animalar scl1cse post1graduate
RESULT:
Thus the database for database management systems has been created successfully.
EX.NO:
DATE:
QUESTION:
"ersonal )nformation =anager /")=0
Ieeping lists of friends, business ac$uaintances, and family in today+s world has
many problems. "eople are always moving, phone numbers are constantly
changing, the number of phone numbers people have today is increasing, and we
have the added complication now of E(=ail addresses and web sites.
The goal of the ")= will be handle the different types of names, addresses, birth
dates, and phone numbers that are important to us. By %eeping an KElectronic+
address boo%, we can have one source that %eeps everything up to date and
accurate.
Le will need to create a list of names that depict the different %inds of problems
this data creates. Families that have %ids6 Families where we need to %now where
both the wife and husband wor%6 ,roups of people that wor% at the same place6
dealing with @ and A digit Mip codes6 reminders when birthdays are near6 handling
all the different phone numbers each person has6 and ma%ing it easy to group
people into different categories are $uestions we need to cover to ma%e our
database successful.
Lith this in mind, we will need to create a database with a minimum of 25 families
and include all of the following criteria
20 Two families where both the wife and husband wor%.
50 Two families with at least 5 %ids.
40 At least four people that wor% for the same company.
D0 Two "ostal codes that include the whole A digit number /e.g.7 AC55A(ED@50.
@0 'ne person who has both a business and home E(=ail address.
B0 'ne person with the title N*octorO.
C0 The spouse in one family has a different last name then main contact.
E0one person who has assistant,list the assistant+s name.
A0one person who holds two #obs.
230 For salutation, list what you would call this person if you phoned them, or
wrote them a letter /e.g.7 *ear 111110. Could be a nic%name /li%e *u%e0 or a very
formal salutation /li%e *r. mith0.
220 Attach a Category to each contact. *ecide if the name is family, business,
friend or any other category of your choosing.
9ot all the fields need to be completed for each family.
AIM:
To create a database for "ersonal )nformation =anager by using data definition
and data manipulation language.
DESCRIPTION:
The *ata *efinition .anguage is used to create an ob#ect/e.g table0,alter the structure
of the table and also drop the ob#ect created. A table is a unit of storage that holds the data in
the form of rows and columns.
The *ata *efinition .anguage is used to
Create the table,
Alter the table,
Truncate the table,
*rop the table.
The *ata manipulation .anguage is used to insert an ob#ect,select is used to display fields and
delete to remove ob#ects inserted. A table is a unit of storage that holds the data in the form of
rows and columns.
The *ata manipulation .anguage is used to
)nsert
elect
Update
*elete.
QUERY/:
select? from pim2 where relationP>husband> '; relationP>wife> A9* #ob is not
null6
OUTPUT:
MN
AM
E
*NAM
E
RELATI
ON
CATE,O
RY .O)
NO(O*(.
O)S
NO(O*(
&IDS
COMPA
NY CODE
NIC&NA
ME
)I0MAI
L +MAIL
mani mith husband family assistant5 4 dell BC smi
acdQgmail.
com
smithQgmail
.com
mani mith husband family cler% 2 5 intel B dear
adQgmail.c
om
vinoQgmail.
com
dhiv
ya
:ic%y husband family assistantB 5@ ms @B null
assQgmail.
com
vic%yQgmail
.com
ra#i :aithi husband family assistantBD 5 mv @3 null
a#Qgmail.c
om
vaithiQgmai
l.com
magi Agil wife business assistantBD 5 mu @A null
a%Qgmail.c
om
agQgmail.co
m
madh
u
indhu wife friend analyst BD 4 ml @2 dear
asQgmail.c
om
amQgmail.c
om
ra# Bhuvi wife friend assitant BE 2 mt @5 null
a$Qgmail.c
om
abQgmail.co
m
ragu )niya wife friend
salesma
n
B3 5 mo @@ null
appQgmail
.com
riQgmail.co
m
simb
u
*hiya wife business assistantBA 5 m% @D null
apQgmail.c
om
riiQgmail.co
m
%uma
r
9athiya wife business cler% BD 4 mf @E paps
auQgmail.c
om
reQgmail.co
m
QUERY1:
select mname,fname from pim2 where no1of1%idsFP56
OUTPUT:
MNAME *NAME
mani smith
ra#i vaithi
magi agil
ra# bhuvi
ragu iniya
simbu dhiya
ra# tamil
QUERY2:
select ?from pim2 where #obP>doctor>6
OUTPUT:
MN
AM
E
*NAM
E
RELATI
ON
CATE,O
RY .O)
NO(O*(.
O)S
NO(O*(&
IDS
COMPA
NY CODE
NIC&NA
ME
)I0MAI
L +MAIL
ra# Tamil wife null doctor B2 5 mr @@ dear
apQgmail.
com
%pQgmail.c
om

QUERY3:
select ?from pim2 where #obP>assistant>6
OUTPUT:
MN
AM
E
*NAM
E
RELATI
ON
CATE,O
RY .O)
NO(O*(.
O)S
NO(O*(
&IDS
COMPA
NY CODE
NIC&NA
ME
)I0MAI
L +MAIL
mani mith husband family
assistan
t
5 4 dell BC smi
acdQgmail.
com
smithQgmail
.com
dhiv
ya
:ic%y husband family
assistan
t
B 5@ ms @B null
assQgmail.
com
vic%yQgmail
.com
ra#i :aithi husband family
assistan
t
BD 5 mv @3 null
a#Qgmail.c
om
vaithiQgmai
l.com
magi Agil wife business
assistan
t
BD 5 mu @A null
a%Qgmail.c
om
agQgmail.co
m
simb
u
*hiya wife business
assistan
t
BA 5 m% @D null
apQgmail.c
om
riiQgmail.co
m
alagu :asanthi wife business
assistan
t
B5 @ mo @@ vaisu
avQgmail.c
om
ssQgmail.co
m
ra# Tamil wife business
assistan
t
B2 5 mr @@ dear
apQgmail.c
om
%pQgmail.co
m
QUERY4:
MN
AM
E
*NAM
E
RELATI
ON
CATE,O
RY .O)
NO(O*(.
O)S
NO(O*(&
IDS
COMPA
NY CODE
NIC&NA
ME
)I0MAI
L +MAIL
mani mith husband family cler% 2 5 intel B dear
adQgmail.
com
vinoQgmail.
com
RESULT:
Thus to create a database for personal information created successfully.
EX.NO:
DATE:
QUESTION:
Rel$$on is a special form of the world view, which is based on the faith in the supernatural
powers, and includes a set of moral values and types of behavior, rituals and gathering of people
into the organiMations /a church, a religious community, etc.0. "eople have always believed that
some supernatural powers and creatures created the world, and all the people, animals, birds and
the ob#ects of nature are the results of their creation. Every religion is based on the opposition of
the real world or the world of the live and the world which waits people after their death. The
e!planation of this opposition is very simple, because the world people live in is full of evil,
stress and difficulties and people have always wanted to escape into the better world and religion
gives them such a possibility claiming that after death everyone will have a better life.
ome religions do not promise a better life but #ust say that the life will be different from the
present one. There are five %ey religions in the world which gather an enormous number of
adherents7 Christianity, )slam, -induism, Chinese fol% religion and Buddhism. ;eligion is $uite
an controversial topic for discussion, because a great number of people do not accept any type of
religion claiming that every religious organiMation is simply an e!cellent way to earn money, rule
people and hide the truth from them. 9o wonder, on the basis of religion there always have been
military conflicts, violence and crimes. )n order to reduce the number of such incidents religion
does not play any role in the political activity of the countries and every person is free to choose
any religion she wants.
)n order to research the topic on religion a student should improve his %nowledge on the whole
topic. A good religion case study is e!pected to be informative, interesting and contain only up(
to(date facts which help to cope with the process of research. A student should collect enough
information to study the case site and understand the cause of the problem which has occurred in
the case. After that he is obliged to analyMe the effect of the problem and brainstorm the best
effective solutions to the problem based on religion.
For the above business stories you are expected to create the following. 1. Analyze the data
required.
2. Normalize the attributes.
AIM:
To create a database for religion by using data definition and data manipulation
language.
DESCRIPTION:
The *ata *efinition .anguage is used to create an ob#ect/e.g table0,alter the structure
of the table and also drop the ob#ect created. A table is a unit of storage that holds the data in
the form of rows and columns.
The *ata *efinition .anguage is used to
Create the table,
Alter the table,
Truncate the table,
*rop the table.
The *ata manipulation .anguage is used to insert an ob#ect,select is used to display fields and
delete to remove ob#ects inserted. A table is a unit of storage that holds the data in the form of
rows and columns.
The *ata manipulation .anguage is used to
)nsert
elect
Update
*elete.
QUERIES:
create table hindu/hindu1name varchar/E0,h1no number/40,hindu1city varchar/E0,h1pop
varchar/D0,h1educated varchar/E0,h1gender varchar/C006
table created.
desc hindu6
OUTPUT:
Table Column Data Type Lent! P"e#$%$on S#ale P"$ma"y &ey Nullable De'ault Comment
-)9*
U
-)9*U19A=E :archar5 E ( ( ( ( (
-19' 9umber ( 4 3 ( ( (
-)9*U1C)T< :archar5 E ( ( ( ( (
-1"'" :archar5 D ( ( ( ( (
-1E*UCATE* :archar5 E ( ( ( ( (
-1,E9*E; :archar5 C ( ( ( ( (
insert into hindu values/>%iruthi>,2,>chennai>,2533,>educated>,>female>06
2 row/s0 inserted.
insert into hindu values/>dhivya>,5,>%arur>,5333,>educated>,>female>06
2 row/s0 inserted.
insert into hindu values/>sindhu>,4,>salem>,4333,>educated>,>female>06
2 row/s0 inserted.
insert into hindu values/>simbu>,D,>nama%%al>,D333,>educated>,>male>06
2 row/s0 inserted.
select ?from hindu6
OUTPUT:
+INDU(NAME +(NO +INDU(CITY +(POP +(EDUCATED +(,ENDER
Iiruthi 2 chennai 2533 educated female
*hivya 5 %arur 5333 educated female
indhu 4 salem 4333 educated female
imbu D nama%%al D333 educated male
create table muslims/m1name varchar/E0,m1no number/50,m1city varchar/E0,m1pop
number/D0,m1educated varchar/E0,m1gender varchar/B006
Table created.
desc muslims6
OUTPUT:
Table Column Data Type Lent! P"e#$%$on S#ale P"$ma"y &ey Nullable De'ault Comment
=U.)=

=19A=E :archar5 E ( ( ( ( (
=19' 9umber ( 5 3 ( ( (
=1C)T< :archar5 E ( ( ( ( (
=1"'" 9umber ( D 3 ( ( (
=1E*UCATE* :archar5 E ( ( ( ( (
=1,E9*E; :archar5 B ( ( ( ( (
insert into muslims values/>banu>,@,>nama%%al>,5@33,>educated>,>female>06
2 row/s0 inserted.
insert into muslims values/>saritha>,B,>%ovai>,4@33,>educated>,>female>06
2 row/s0 inserted.
insert into muslims values/>irfan>,C,>asham>,@@33,>educated>,>male>06
2 row/s0 inserted.
insert into muslims values/>sanu>,E,>trichy>,2@33,>educated>,>female>06
2 row/s0 inserted.
select ?from muslims6
OUTPUT:
M(NAME M(NO M(CITY M(POP M(EDUCATED M(,ENDER
banu @ nama%%al 5@33 Educated female
saritha B %ovai 4@33 Educated female
irfan C asham @@33 Educated male
sanu E trichy 2@33 Educated female
create table christians/c1name varchar/@0,c1no number/50,c1city varchar/B0,c1educated
varchar/C0,c1gender varchar/B006
Table created.
desc christians6
OUTPUT:
Table Column Data Type Lent! P"e#$%$on S#ale P"$ma"y &ey Nullable De'ault Comment
C-;)T)A
9
C19A=E :archar5 @ ( ( ( ( (
C19' 9umber ( 5 3 ( ( (
C1C)T< :archar5 B ( ( ( ( (
C1E*UCATE* :archar5 C ( ( ( ( (
C1,E9*E; :archar5 B ( ( ( ( (
insert into christians values/>sri#a>,A,>trichy>,>unedu>,>female>06
2 row/s0 inserted.
insert into christians values/>hema>,23,>hosur>,>educate>,>female>06
2 row/s0 inserted.
insert into christians values/>vic%y>,23,>%arur>,>educate>,>male>06
2 row/s0 inserted.
insert into christians values/>vino>,23,>salem>,>educate>,>male>06
2 row/s0 inserted.
insert into christians values/>sri>,23,>hosur>,>educate>,>male>06
2 row/s0 inserted.
select ?from christians6
OUTPUT:
C(NAME C(NO C(CITY C(EDUCATED C(,ENDER
sri#a A trichy unedu Female
hema 23 hosur educate Female
vic%y 23 %arur educate =ale
vino 23 salem educate =ale
sri 23 hosur educate =ale
RESULT:
Thus to create a database for religion has been created successfully.
EX.NO:
DATE:
QUESTION:
Choose one application area e.g. a supermar%et,ban%, airport, university, and so on6 briefly
e!plain steps to design a database for this application area.
AIM:
To create a employee database by using data definition language and data manipulation
language.
DESCRIPTION:
The *ata *efinition .anguage is used to create an ob#ect/e.g table0,alter the structure
of the table and also drop the ob#ect created. A table is a unit of storage that holds the data in
the form of rows and columns.
The *ata *efinition .anguage is used to
Create the table,
Alter the table,
Truncate the table,
*rop the table.
The *ata manipulation .anguage is used to insert an ob#ect,select is used to display fields and
delete to remove ob#ects inserted. A table is a unit of storage that holds the data in the form of
rows and columns.
The *ata manipulation .anguage is used to
)nsert
elect
Update
*elete.
QUERIES:
Table creation7
create table emp2/empname varchar/230,empno number,salary number,hiredate
varchar/230,deptno number06
table created.
*esc emp26
OUTPUT:
Tabl
e Column Data Type Lent! P"e#$%$on S#ale P"$ma"y &ey Nullable De'ault Comment
E="2 E="9A=E :archar5 23 ( ( ( ( (
E="9' 9umber ( ( ( ( ( (
A.A;< 9umber ( ( ( ( ( (
-);E*ATE :archar5 23 ( ( ( ( (
*E"T9' 9umber ( ( ( ( ( (
Alter table emp2 modify/empname/2@006
Table altered.
desc emp26
OUTPUT:
Tabl
e Column Data Type Lent! P"e#$%$on S#ale P"$ma"y &ey Nullable De'ault Comment
E="2 E="9A=E :archar5 2@ ( ( ( ( (
E="9' 9umber ( ( ( ( ( (
A.A;< 9umber ( ( ( ( ( (
-);E*ATE :archar5 23 ( ( ( ( (
*E"T9' 9umber ( ( ( ( ( (
)nsertion7
insert into emp2 values/>%irthi>,254D,25333,>2E(nov(AD>,2306
2 row/s0 inserted.
insert into emp2 values/>dhivya>,2545,45333,>5B(nov(AD>,5306
2 row/s0 inserted.
insert into emp2 values/>sindhu>,254D,45B33,>5E(nov(AD>,D306
2 row/s0 inserted.
insert into emp2 values/>priya>,554D,4533,>5E(feb(AD>,4306
2 row/s0 inserted.
insert into emp2 values/>srimathi>,554E,45333,>5E(#an(AD>,@306
2 row/s0 inserted.
select ?from emp26
employee table7
OUTPUT:
EMPNAME EMPNO SALARY +IREDATE DEPTNO
Iirthi 254D 25333 2E(nov(AD 23
*hivya 2545 45333 5B(nov(AD 53
indhu 254D 45B33 5E(nov(AD D3
"riya 554D 4533 5E(feb(AD 43
rimathi 554E 45333 5E(#an(AD @3
select count/emp9ame0 from emp26
OUTPUT:
COUNT5EMPNAME6
@
select ma!/salary0 from emp26
OUTPUT:
MAX5SALARY6
45B33
Creation of table57
create table dept/deptno number,deptname varchar/23006
Table created.
desc dept6
OUTPUT:
Tabl
e Column Data Type Lent! P"e#$%$on S#ale P"$ma"y &ey Nullable De'ault Comment
*E"T *E"T9' 9umber ( ( ( ( ( (
*E"T9A=E :archar5 23 ( ( ( ( (
)nsertion7
insert into dept values/23,>salesman>06
2 row/s0 inserted.
insert into dept values/53,>analyst>06
2 row/s0 inserted.
insert into dept values/43,>manager>06
2 row/s0 inserted.
elect ?from dept6
OUTPUT:
DEPTNO DEPTNAME
23 salesman
53 analyst
43 manager
)nner #oin7
select emp2.empname,emp2.salary from emp2 inner #oin dept on emp2.deptnoPdept.deptno6
OUTPUT:
EMPNAME SALARY
Iirthi 25333
*hivya 45333
"riya 4533
Full #oin7
select emp2.empname,emp2.hiredate,emp2.salary,dept.deptname from emp2 full #oin dept on
emp2.deptnoPdept.deptno6
OUTPUT:
EMPNAME +IREDATE SALARY DEPTNAME
Iirthi 2E(nov(AD 25333 salesman
*hivya 5B(nov(AD 45333 analyst
"riya 5E(feb(AD 4533 manager
rimathi 5E(#an(AD 45333 (
indhu 5E(nov(AD 45B33 (
select ?from emp2 order by salary desc6
OUTPUT:
EMPNAME EMPNO SALARY +IREDATE DEPTNO
sindhu 254D 45B33 5E(nov(AD D3
dhivya 2545 45333 5B(nov(AD 53
srimathi 554E 45333 5E(#an(AD @3
%irthi 254D 25333 2E(nov(AD 23
priya 554D 4533 5E(feb(AD 43
select hiredate from emp2 group by hiredate6
OUTPUT:
+IREDATE
5E(feb(AD
5E(#an(AD
2E(nov(AD
5B(nov(AD
5E(nov(AD
select upper/empname0 from emp26
OUTPUT:
UPPER5EMPNAME6
I);T-)
*-):<A
)9*-U
";)<A
;)=AT-)
update dept set deptnoP23 where deptnameP>salesman>6
2 row/s0 updated.
delete from emp2 where deptnoP@36
2 row/s0 deleted.
select ?from emp26
OUTPUT:
EMPNAME EMPNO SALARY +IREDATE DEPTNO
%irthi 254D 25333 2E(nov(AD 23
dhivya 2545 45333 5B(nov(AD 53
sindhu 254D 45B33 5E(nov(AD D3
priya 554D 4533 5E(feb(AD 43
RESULT:
Thus the data base for employee details has been created successfully.
EX.NO:
DATE:
QUESTION:
Create a database for student details.
AIM:
To create a database for student details.
DESCRIPTION:
The *ata *efinition .anguage is used to create an ob#ect/e.g table0,alter the structure
of the table and also drop the ob#ect created. A table is a unit of storage that holds the data in
the form of rows and columns.
The *ata *efinition .anguage is used to
Create the table,
Alter the table,
Truncate the table,
*rop the table.
The *ata manipulation .anguage is used to insert an ob#ect,select is used to display fields and
delete to remove ob#ects inserted. A table is a unit of storage that holds the data in the form of
rows and columns.
The *ata manipulation .anguage is used to
)nsert
elect
Update
*elete.
QUERY:
TA)LE CREATION:
create table students/rollno number primary %ey,studentname varchar/230,dateofbirth
varchar/230,age number06
Table created.
desc students6
OUTPUT:
Table Column Data Type Lent! P"e#$%$on S#ale P"$ma"y &ey Nullable De'ault Comment
TU*E9
T
;'..9' 9umber ( ( ( 2 ( ( (
TU*E9T9A=E :archar5 23 ( ( ( ( (
*ATE'FB);T- :archar5 23 ( ( ( ( (
A,E 9umber ( ( ( ( ( (
INSERTION:
insert into students values/254D,>%iruthi%a>,>2E(nov(AD>,2E06
2 row/s0 inserted.
insert into students values/254@,>dhivya>,>3B(oct(A@>,2C06
2 row/s0 inserted.
insert into students values/254B,>sindhu#a>,>3D(mar(A@>,2C06
2 row/s0 inserted.
insert into students values/254C,>bhuvana>,>2C(#une(AD>,2E06
2 row/s0 inserted.
insert into students values/254E,>vini>,>5@(#une(AD>,2E06
2 row/s0 inserted.
insert into students values/25D3,>sri#a>,>23(#une(AD>,2E06
2 row/s0 inserted.
insert into students values/25D5,>%ishor>,>25(dec(A4>,2B06
2 row/s0 inserted.
select ?from students6
OUTPUT:
ROLLNO STUDENTNAME DATEO*)IRT+ A,E
254D Iiruthi%a 2E(nov(AD 2E
254@ *hivya 3B(oct(A@ 2C
254B indhu#a 3D(mar(A@ 2C
254C Bhuvana 2C(#une(AD 2E
254E :ini 5@(#une(AD 2E
25D3 ri#a 23(#une(AD 2E
25D5 Iishor 25(dec(A4 2B
TA)LE CREATION:
create table results/rollno references students/rollno0,os varchar/50,dbms varchar/50,ds
varchar/50,percentage number06
Table created.
desc results6
OUTPUT:
Table Column Data Type Lent! P"e#$%$on S#ale P"$ma"y &ey Nullable De'ault Comment
;EU.T

;'..9' 9umber ( ( ( ( ( (
' :archar5 5 ( ( ( ( (
*B= :archar5 5 ( ( ( ( (
* :archar5 5 ( ( ( ( (
"E;CE9TA,E 9umber ( ( ( ( ( (
INSERTION:
insert into results values/254D,>A>,>B>,>>,A306
2 row/s0 inserted.
insert into results values/254@,>C>,>>,>E>,E@06
2 row/s0 inserted.
insert into results values/254B,>C>,>A>,>B>,CA06
2 row/s0 inserted.
insert into results values/254C,>C>,>A>,>>,BA06
2 row/s0 inserted.
insert into results values/254E,>>,>B>,>A>,EE06
2 row/s0 inserted.
insert into results values/25D3,>C>,>B>,>*>,AB06
2 row/s0 inserted.
insert into results values/25D5,>*>,>B>,>A>,AC06
2 row/s0 inserted.
select ?from results6
OUTPUT:
ROLLNO OS D)MS DS PERCENTA,E
254D A B A3
254@ C E E@
254B C A B CA
254C C A BA
254E B A EE
25D3 C B * AB
25D5 * B A AC
INNER .OIN:
select students.rollno,students.studentname,students.dateofbirth,results.dbms from students inner
#oin results on students.rollnoPresults.rollno6
OUTPUT:
ROLLNO STUDENTNAME DATEO*)IRT+ D)MS
254D Iiruthi%a 2E(nov(AD B
254@ *hivya 3B(oct(A@
254B indhu#a 3D(mar(A@ A
254C Bhuvana 2C(#une(AD A
254E :ini 5@(#une(AD B
25D3 ri#a 23(#une(AD B
25D5 Iishor 25(dec(A4 B
COUNTIN,:
select count/studentname0 from students6
OUTPUT:
COUNT5STUDENTNAME6
C
ORDER )Y:
select ?from results order by percentage desc6
OUTPUT:
ROLLNO OS D)MS DS PERCENTA,E
25D5 * B A AC
25D3 C B * AB
254D A B A3
254E B A EE
254@ C E E@
254B C A B CA
254C C A BA
,ROUP )Y:
select dateofbirth from students group by dateofbirth6
OUTPUT:
DATEO*)IRT+
2E(nov(AD
3B(oct(A@
23(#une(AD
3D(mar(A@
5@(#une(AD
2C(#une(AD
25(dec(A4
MAXIMUM:
select ma!/percentage0 from results6
OUTPUT:
MAX5PERCENTA,E6
AC
UPPERCASE:
select upper/studentname0 from students6
OUTPUT:
UPPER5STUDENTNAME6
I);UT-)IA
*-):<A
)9*-UJA
B-U:A9A
:)9)
;)JA
I)-';
+A-IN,:
select rollno,sum/percentage0 from results having sum/percentage0F533 group by rollno6
OUTPUT:
ROLLNO SUM5PERCENTA,E6
25D3 AB
254E EE
25D5 AC
254D A3
254B CA
254C BA
254@ E@
LO,ICAL OPERATION:
select ?from results where percentage between A3 A9* 2336
OUTPUT:
ROLLNO OS D)MS DS PERCENTA,E
254D A B A3
25D3 C B * AB
25D5 * B A AC
LI&E:
select ?from students where studentname li%e >%R>6
OUTPUT:
ROLLNO STUDENTNAME DATEO*)IRT+ A,E
254D Iiruthi%a 2E(nov(AD 2E
25D5 Iishor 25(dec(A4 2B
select os from results where percentageP/select percentage from results where rollnoP254D and
percentagePA306
OS
A
RESULT:
Thus the database for students has been created successfully.
EX.NO:
DATE:
QUESTION:
20*isplay the names of employees whose names have second alphabet A in their names.
50 select the names of the employee whose names is e!actly five characters in length.
40 *isplay the names of the employee who are not wor%ing as =A9A,E;.
D0 *isplay the names of the employee who are not wor%ing as A.E=A9 '; C.E;I ';
A9A.<T.
@0 *isplay all rows from emp table.The system should wait after every screen full of
informaction.
B0*isplay the total number of employee wor%ing in the company.
C0 *isplay the total salary beiging paid to all employees.
E0 *isplay the ma!imum salary from emp table.
A0 *isplay the minimum salary from emp table.
230 *isplay the average salary from emp table.
AIM:
To perform s$l $ueries on employee table.
DESCRIPTION:
The *ata *efinition .anguage is used to create an ob#ect/e.g table0,alter the structure
of the table and also drop the ob#ect created. A table is a unit of storage that holds the data in
the form of rows and columns.
The *ata *efinition .anguage is used to
Create the table,
Alter the table,
Truncate the table,
*rop the table.
The *ata manipulation .anguage is used to insert an ob#ect,select is used to display fields and
delete to remove ob#ects inserted. A table is a unit of storage that holds the data in the form of
rows and columns.
The *ata manipulation .anguage is used to
)nsert
elect
Update
*elete.
QUERY/:
select concat/first1name,last1name0 as name from employees5 where first1name .)IE >1aR>6
OUTPUT:
NAME
;andall=atos
"atFay
QUERY1:
select concat/first1name,last1name0 as name from employees5 where length/first1name0P@6
OUTPUT:
NAME
9eena%ochhar
BruceErnst
*iana.orentM
Iebin=ourgos
"eter:argas
EleniSlot%ey
EllenAbel
QUERY2:
select employees5.first1name,employees5.last1name,#obs.#ob1title from employees5 inner #oin
#obs on employees5.#ob1idP#obs.#ob1id where #obs.#ob1idTP>A1=A9> and #obs.#ob1idT
P>AC1=,;> A9* #obs.#ob1idTP>T1=A9> and #obs.#ob1idTP>=I1=A9>6
OUTPUT:
*IRST(NAME LAST(NAME .O)(TITLE
teven Iing "resident
9eena Iochhar Administration :ice "resident
.e! *ehaan Administration :ice "resident
Ale!ander -unold "rogrammer
Bruce Ernst "rogrammer
*iana .orentM "rogrammer
Trenna ;a#s toc% Cler%
Curtis *avies toc% Cler%
;andall =atos toc% Cler%
"eter :argas toc% Cler%
Ellen Abel ales ;epresentative
Jonathon Taylor ales ;epresentative
Iimberely ,rant ales ;epresentative
Jennifer Lhalen Administration Assistant
"at Fay =ar%eting ;epresentative
Lilliam ,ietM "ublic Accountant
QUERY3:
select employees5.first1name,employees5.last1name,#obs.#ob1title from employees5 inner #oin
#obs on employees5.#ob1idP#obs.#ob1id where #obs.#ob1idTP>A1=A9> and #obs.#ob1idT
P>T1C.E;I>6
OUTPUT:
*IRST(NAME LAST(NAME .O)(TITLE
teven Iing "resident
9eena Iochhar Administration :ice "resident
.e! *ehaan Administration :ice "resident
Ale!ander -unold "rogrammer
Bruce Ernst "rogrammer
*iana .orentM "rogrammer
Iebin =ourgos toc% =anager
Ellen Abel ales ;epresentative
Jonathon Taylor ales ;epresentative
Iimberely ,rant ales ;epresentative
Jennifer Lhalen Administration Assistant
=ichael -artstein =ar%eting =anager
"at Fay =ar%eting ;epresentative
heliey -iggins Accounting =anager
Lilliam ,ietM "ublic Accountant
QUERY4:
select first1nameUUlast1name as employee1name,salary from employees order by salary desc6
OUTPUT:
EMPLOYEE(NAME SALARY
steven%ing 5D333
9eena%ochhar 2C333
.e!*ehaan 2C333
heliey-iggins 25333
EllenAbel 22333
EleniSlot%ey 23@33
Ale!ander-unold A333
JonathonTaylor EB33
Lilliam,ietM E433
Iimberely,rant C333
BruceErnst B333
"atFay B333
Iebin=ourgos @E33
JenniferLhalen DD33
*iana.orentM D533
Trenna;a#s 4@33
Curtis*avies 4233
;andall=atos 5B33
"eter:argas 5@33

QUERY7:
select count/first1name0 from employees56
OUTPUT:
COUNT5*IRST(NAME6
53
QUERY8:
select sum/salary0from employees56
OUTPUT:
SUM5SALARY6
2C@@33
QUERY9:
select ma!/salary0 from employees56
OUTPUT:
MAX5SALARY6
5D333
QUERY::
select min/salary0 from employees56
OUTPUT:
MIN5SALARY6
5@33
QUERY/;:
select avg/salary0 from employees56
OUTPUT:
A-,5SALARY6
ECC@
RESULT:
Thus the s$l $ueries were performed on employee table and verified successfully.
EX.NO:
DATE:
QUESTION:
20 *isplay the informaction from emp table.Lhere #ob manager is found it
should be displayed as boos/Use replace function0.
50 *isplay empno,ename,deptno from emp table.)nstead of display department
numbers display the related department name/Use decode function0.
40 *isplay your age in days.
D0 *isplay your age in months.
@0 *isplay the current date as 2@th Augest Friday 9ineteen 9inety aven.
B0 *isplay the following output for each row from emp table.
scott has #oined the company on wednesday 24th August ninten nintey.
C0 Find the date for nearest saturday after current date.
E0 *isplay current time.
A0 *isplay the date three months Before the current date.
230 *isplay the common #obs from department number 23 and 53.
AIM:
To perform s$l $ueries on employee table.
DESCRIPTION:
The *ata *efinition .anguage is used to create an ob#ect/e.g table0,alter the structure
of the table and also drop the ob#ect created. A table is a unit of storage that holds the data in
the form of rows and columns.
The *ata *efinition .anguage is used to
Create the table,
Alter the table,
Truncate the table,
*rop the table.
The *ata manipulation .anguage is used to insert an ob#ect,select is used to display fields and
delete to remove ob#ects inserted. A table is a unit of storage that holds the data in the form of
rows and columns.
The *ata manipulation .anguage is used to
)nsert
elect
Update
*elete.
QUERY /:
select replace/J'B1)*,>=A9A,E;>,>B'>0 from employees56
OUTPUT:
REPLACE5.O)(ID< =MANA,ER=<=)OSS=6
A*1";E
A*1:"
A*1:"
)T1";',
)T1";',
)T1";',
T1=A9
T1C.E;I
T1C.E;I
T1C.E;I
T1C.E;I
A1=A9
A1;E"
A1;E"
A1;E"
A*1AT
=I1=A9
=I1;E"
AC1=,;
AC1ACC'U9T
QUERY 1:
select employee1id,concat/first1name,last1name0as
name,hire1date,decode/department1id,23,>ACC'U9T)9,>,53,>;EEA;C->,43,>A.E>,D3,>'"
;AT)'9>0 from employees56
OUTPUT:
EMPLOYE
E(ID NAME
+IRE(DAT
E
DECODE5DEPARTMENT(ID< /;< =ACCOUNTIN,=< 1;< =RESEARC+=< 2
;< =SALES=<3;<=OPRATIONS=6
233 teven%ing 2C(JU9(EC (
232 9eena%ochhar 52(E"(EA (
235 .e!*ehaan 2C(JA9(A4 (
234
Ale!ander-un
old
34(JA9(A3 (
23D BruceErnst 52(=A<(A2 (
23C *iana.orentM 3C(FEB(AA (
25D Iebin=ourgos 2B(9':(AA (
2D2 Trenna;a#s 2C('CT(A@ (
2D5 Curtis*avies 5A(JA9(AC (
2D4 ;andall=atos 2@(=A;(AE (
2DD "eter:argas 3A(JU.(AE (
2DA EleniSlot%ey 5A(JA9(33 (
2CD EllenAbel 22(=A<(AB (
2CB
JonathonTaylo
r
5D(=A;(AE (
2CE Iimberely,ra 5D(=A<(AA (
nt
533
JenniferLhale
n
2C(E"(EC ACC'U9T)9,
532
=ichael-artste
in
2C(FEB(AB ;EEA;C-
535 "atFay 2C(AU,(AC ;EEA;C-
53@
heliey-iggin
s
3C(JU9(AD (
53B Lilliam,ietM 3C(JU9(AD (

QUERY 2:
select to1date/sysdate0(to1date/>2E(nov(AD>0from dual6
OUTPUT:
TO(DATE5SYSDATE6>TO(DATE5=/9>NO->:3=6
C32A
QUERY 3:
select months1between/sysdate,>2E(nov(AD>0 from dual6
OUTPUT:
MONT+S()ET?EEN5SYSDATE< =/9>NO->:3=6
543.B3B3E@4DADB54B@@A24ACEDADB54B@@A24AE
QUERY 4:
select to1char/sysdate,>ddth month day year>0as Vcurrent dateV from dual6
OUTPUT:
Cu""ent Date
3@th february wednesday twenty fourteen
QUERY 7:
select first1name UU> -A J')9E* T-E C'="A9< '9 >UUto1char/hire1date,>day ddth =onth
year>0 from employees56
OUTPUT:
*IRST(NAME@ @ =+AS.OINEDT+ECOMPANYON=@ @ TO(C+AR5+IRE(DATE< =DAYDDT+MONT+YEAR=6
steven -A J')9E* T-E C'="A9< '9 wednesday 2Cth June nineteen eighty(seven
9eena -A J')9E* T-E C'="A9< '9 thursday 52st eptember nineteen eighty(nine
.e! -A J')9E* T-E C'="A9< '9 sunday 2Cth January nineteen ninety(three
Ale!ander -A J')9E* T-E C'="A9< '9 wednesday 34rd January nineteen ninety
Bruce -A J')9E* T-E C'="A9< '9 tuesday 52st =ay nineteen ninety(one
*iana -A J')9E* T-E C'="A9< '9 sunday 3Cth February nineteen ninety(nine
Iebin -A J')9E* T-E C'="A9< '9 tuesday 2Bth 9ovember nineteen ninety(nine
Trenna -A J')9E* T-E C'="A9< '9 tuesday 2Cth 'ctober nineteen ninety(five
Curtis -A J')9E* T-E C'="A9< '9 wednesday 5Ath January nineteen ninety(seven
;andall -A J')9E* T-E C'="A9< '9 sunday 2@th =arch nineteen ninety(eight
"eter -A J')9E* T-E C'="A9< '9 thursday 3Ath July nineteen ninety(eight
Eleni -A J')9E* T-E C'="A9< '9 saturday 5Ath January two thousand
Ellen -A J')9E* T-E C'="A9< '9 saturday 22th =ay nineteen ninety(si!
Jonathon -A J')9E* T-E C'="A9< '9 tuesday 5Dth =arch nineteen ninety(eight
Iimberely -A J')9E* T-E C'="A9< '9 monday 5Dth =ay nineteen ninety(nine
Jennifer -A J')9E* T-E C'="A9< '9 thursday 2Cth eptember nineteen eighty(seven
=ichael -A J')9E* T-E C'="A9< '9 saturday 2Cth February nineteen ninety(si!
"at -A J')9E* T-E C'="A9< '9 sunday 2Cth August nineteen ninety(seven
heliey -A J')9E* T-E C'="A9< '9 tuesday 3Cth June nineteen ninety(four
Lilliam -A J')9E* T-E C'="A9< '9 tuesday 3Cth June nineteen ninety(four
QUERY 8:
select ne!t1day/sysdate,>saturday>0from dual6
OUTPUT:
NEXT(DAY5SYSDATE<=SATURDAY=6
3E(FEB(2D
QUERY 9:
select to1char/sysdate,>dy dd(mon(yyyy hh5D7mi7ss>0as Vcurrent date&timeV from dual6
OUTPUT:
Cu""ent DateAT$me
wed 3@(feb(532D 2E74@7D4
QUERY ::
select add1months/sysdate,40 from dual6
OUTPUT:
ADD(MONT+S5SYSDATE< 26
3@(=A<(2D
QUERY /;:
select department1name from departments where department1idP23 and department1idP536
OUTPUT:
no data found
RESULT:
Thus the s$l $ueries were performed on employee table and verified successfully.
EX.NO:
DATE:
QUESTION:
20 *isplay those employee whose deptno is available in salaryW
50 *isplay those employee whose first 5 characters from hiredate (last 5
characters of salaryW
40 *isplay empno,ename,deptno,sal sort the output first base on name and within name by
deptno and with in deptno by sal.
D0 *isplay those employee who are wor%ing in sales or researchW
@0 elect department,total salary with respect to a department from employee table where total
salary greater than 2@333 order by Total1alary descending.
B0 *isplay those employees who #oined the company before 2@ of the monthW
C0 *isplay those employee who has #oined before 2@th of the month.
E0-ow can ) create an empty table emp2 with same structure as empW
A0 *isplay the name of the employee along with their annual salary/sal?250. The name of the
employee earning highest annual salary should apper first.
230 *isplay those employees who are wor%ing as manager.
AIM:
To perform s$l $ueries on employee table.
DESCRIPTION:
The *ata *efinition .anguage is used to create an ob#ect/e.g table0,alter the structure
of the table and also drop the ob#ect created. A table is a unit of storage that holds the data in
the form of rows and columns.
The *ata *efinition .anguage is used to
Create the table,
Alter the table,
Truncate the table,
*rop the table.
The *ata manipulation .anguage is used to insert an ob#ect,select is used to display fields and
delete to remove ob#ects inserted. A table is a unit of storage that holds the data in the form of
rows and columns.
The *ata manipulation .anguage is used to
)nsert
elect
Update
*elete.
QUERY /:
select ? from employees5 where instr/salary,department1id,2,20G36
OUTPUT:
EMPLO
YEE(ID
*IRST(N
AME
LAST(N
AME
EMAI
L
P+ONE(N
UM)ER
+IRE(D
ATE
.O)(I
D
SALA
RY
COMMISSI
ON(PCT
MANA,E
R(ID
DEPARTM
ENT(ID
23D Bruce Ernst
BE;9
T
@A3.D54.D@BE
52(=A<(
A2
)T1";'
,
B333 ( 234 B3
2D2 Trenna ;a#s T;AJ B@3.252.E33A
2C('CT(
A@
T1C.E
;I
4@33 ( 25D @3
2DD "eter :argas
":A;,
A
B@3.252.533D 3A(JU.(AE
T1C.E
;I
5@33 ( 25D @3
QUERY 1:
select substr/hire1date,3,50UUsubstr/salary,length/salary0(2,50 from employees56
OUTPUT:
SU)STR5+IRE(DATE< ;<16@ @ SU)STR5SALARY< LEN,T+5SALARY6>/< 16
2C33
5233
2C33
3433
5233
3C33
2B33
2C33
5A33
2@33
3A33
5A33
2233
5D33
5D33
2C33
2C33
2C33
3C33
3C33
QUERY 2:
select employee1id,first1name,department1id,salary from employees order by
first1name,department1id,salary6
OUTPUT:
EMPLOYEE(ID *IRST(NAME DEPARTMENT(ID SALARY
234 Ale!ander B3 A333
23D Bruce B3 B333
2D5 Curtis @3 4233
23C *iana B3 D533
2DA Eleni E3 23@33
2CD Ellen E3 22333
533 Jennifer 23 DD33
2CB Jonathon E3 EB33
25D Iebin @3 @E33
2CE Iimberely ( C333
235 .e! A3 2C333
232 9eena A3 2C333
535 "at 53 B333
2DD "eter @3 5@33
2D4 ;andall @3 5B33
53@ heliey 223 25333
2D2 Trenna @3 4@33
53B Lilliam 223 E433
233 teven A3 5D333

QUERY 3:
select employees5.first1name,employees5.last1name,#obs.#ob1title from employees5 inner #oin
#obs on employees5.#ob1idP#obs.#ob1id where #obs.#ob1idP>A1=A9> or #obs.#ob1idT
P>A1;E">6
OUTPUT:
*IRST(NAME LAST(NAME .O)(TITLE
teven Iing "resident
9eena Iochhar Administration :ice "resident
.e! *ehaan Administration :ice "resident
Ale!ander -unold "rogrammer
Bruce Ernst "rogrammer
*iana .orentM "rogrammer
Iebin =ourgos toc% =anager
Trenna ;a#s toc% Cler%
Curtis *avies toc% Cler%
;andall =atos toc% Cler%
"eter :argas toc% Cler%
Eleni Slot%ey ales =anager
Jennifer Lhalen Administration Assistant
=ichael -artstein =ar%eting =anager
"at Fay =ar%eting ;epresentative
heliey -iggins Accounting =anager
Lilliam ,ietM "ublic Accountant
QUERY 4:
select first1nameUUlast1name as employee1name,salary,department1id from employees where
salaryG2@333 order by salary desc6
OUTPUT:
EMPLOYEE(NAME SALARY DEPARTMENT(ID
steven%ing 5D333 A3
.e!*ehaan 2C333 A3
9eena%ochhar 2C333 A3

QUERY 7:
select concat/first1name,last1name0as name from employees5 where
to1char/hire1date,>**>0F2@6
OUTPUT:
NAME
Ale!ander-unold
*iana.orentM
"eter:argas
EllenAbel
heliey-iggins
Lilliam,ietM
QUERY 8:
select concat/first1name,last1name0as name from employees5 where
to1char/hire1date,>**>0F2@6
OUTPUT:
NAME
Ale!ander-unold
*iana.orentM
"eter:argas
EllenAbel
heliey-iggins
Lilliam,ietM
QUERY 9:
create table emp as select ?from employees where 2P36
select ?from emp6
OUTPUT:
no data found

QUERY ::
select first1nameUUlast1name as employee1name,/salary?250 as annual1salary from employees
order by /salary?250 desc6
OUTPUT:
EMPLOYEE(NAME ANNUAL(SALARY
steven%ing 5EE333
9eena%ochhar 53D333
.e!*ehaan 53D333
heliey-iggins 2DD333
EllenAbel 245333
EleniSlot%ey 25B333
Ale!ander-unold 23E333
JonathonTaylor 234533
Lilliam,ietM AAB33
Iimberely,rant ED333
BruceErnst C5333
"atFay C5333
Iebin=ourgos BAB33
JenniferLhalen @5E33
*iana.orentM @3D33
Trenna;a#s D5333
Curtis*avies 4C533
;andall=atos 42533
"eter:argas 43333
QUERY /;:
select
employees5.first1name,employees5.last1name,#obs.#ob1title
from employees5 inner #oin #obs on
employees5.#ob1idP#obs.#ob1id where #obs.#ob1idP>AC1=,;>
or #obs.#ob1idP>A1=A9> or #obs.#ob1idP>T1=A9> or
#obs.#ob1idP>=I1=A9>6
OUTPUT:

*IRST(NAME LAST(NAME .O)(TITLE
heliey -iggins
Accounting
=anager
Eleni Slot%ey ales =anager
Iebin =ourgos toc% =anager
=ichael -artstein
=ar%eting
=anager
RESULT:
Thus the s$l $ueries were performed on employee table and verified successfully.
EX.NO:
DATE:
QUESTION:
20 To fetch A.TE;9ATE records from a table. /E:E9 9U=BE;E*0
50 To select A.TE;9ATE records from a table. /'** 9U=BE;E*0
40Find the 4rd =AX salary in the emp table.
D0Find the 4rd =)9 salary in the emp table.
@0 elect F);T n records from a table.
B0elect .AT n records from a table
employees in the department.
C0.ist dept no., *ept name for all the departments in which there are no
E0-ow to get 4 =a! salaries W
A0 -ow to get 4 =in salaries W
230 -ow to get nth ma! salaries W
AIM:
To perform s$l $ueries on employee table.
DESCRIPTION:
The *ata *efinition .anguage is used to create an ob#ect/e.g table0,alter the structure
of the table and also drop the ob#ect created. A table is a unit of storage that holds the data in
the form of rows and columns.
The *ata *efinition .anguage is used to
Create the table,
Alter the table,
Truncate the table,
*rop the table.
The *ata manipulation .anguage is used to insert an ob#ect,select is used to display fields and
delete to remove ob#ects inserted. A table is a unit of storage that holds the data in the form of
rows and columns.
The *ata manipulation .anguage is used to
)nsert
elect
Update
*elete.
QUERY /:
select ? from employees5 where /rowid,30 in /select rowid,mod/rownum,50 from employees506
OUTPUT:
EMPL
OYEE(
ID
*IRST(N
AME
LAST(N
AME EMAIL
P+ONE(N
UM)ER
+IRE(D
ATE .O)(ID
SALA
RY
COMMISSI
ON(PCT
MANA,
ER(ID
DEPARTM
ENT(ID
232 9eena %ochhar
9I'C-
-A;
@2@.254.D@E
52(E"(
EA
A*1:" 2C333 ( 233 A3
234 Ale!ander -unold
A-U9'
.*
@A3.D54.D@BC
34(JA9(
A3
)T1";', A333 ( 235 B3
23C *iana .orentM
*.';E
9TS
@A3.D54.@@BC
3C(FEB(
AA
)T1";', D533 ( 234 B3
2D2 Trenna ;a#s T;AJ B@3.252.E33A
2C('CT(
A@
T1C.E;
I
4@33 ( 25D @3
2D4 ;andall =atos
;=AT'

B@3.252.5ECD
2@(=A;(
AE
T1C.E;
I
5B33 ( 25D @3
2DA Eleni Slot%ey
ES.'TI
E<
322.DD.24DD.
D5A32E
5A(JA9(
33
A1=A9 23@33 3 233 E3
2CB Jonathon Taylor
JTA<.'
;
322.DD.2BDD.
D5A5B@
5D(=A;(
AE
A1;E" EB33 3 2DA E3
533 Jennifer Lhalen
JL-A.
E9
@2@.254.DDDD
2C(E"(
EC
A*1ATDD33 ( 232 23
535 "at Fay "FA< B34.254.BBBB
2C(AU,(
AC
=I1;E" B333 ( 532 53
53B Lilliam ,ietM L,)ETS@2@.254.E2E2
3C(JU9(
AD
AC1ACC
'U9T
E433 ( 53@ 223
QUERY 1:
select ? from employees5 where /rowid,20 in /select rowid,mod/rownum,50 from employees506
OUTPUT:
EMPLO
YEE(I
D
*IRST(N
AME
LAST(N
AME EMAIL
P+ONE(N
UM)ER
+IRE(D
ATE
.O)(I
D
SALA
RY
COMMISSI
ON(PCT
MANA,E
R(ID
DEPARTM
ENT(ID
233 steven %ing I)9, @2@.254.D@BC
2C(JU9(
EC
A*1";
E
5D333 ( ( A3
235 .e! *ehaan
.*E-A
A9
@2@.254.D@BA
2C(JA9(
A4
A*1:" 2C333 ( 233 A3
23D Bruce Ernst BE;9T @A3.D54.D@BE
52(=A<(
A2
)T1";'
,
B333 ( 234 B3
25D Iebin =ourgos
I='U;
,'
B@3.254.@54D
2B(9':(
AA
T1=A
9
@E33 ( 233 @3
2D5 Curtis *avies
C*A:)E

B@3.252.5AAD
5A(JA9(
AC
T1C.E
;I
4233 ( 25D @3
2DD "eter :argas
":A;,
A
B@3.252.533D 3A(JU.(AE
T1C.E
;I
5@33 ( 25D @3
2CD Ellen Abel EABE.
322.DD.2BDD.D
5A5BC
22(=A<(
AB
A1;E"22333 3 2DA E3
2CE Iimberely ,rant
I,;A9
T
322.DD.2BDD.D
5A5B4
5D(=A<(
AA
A1;E"C333 3 2DA (
532 =ichael -artstein
=-A;T
TE
@2@.254.@@@@
2C(FEB(
AB
=I1=
A9
24333 ( 233 53
53@ heliey -iggins
-),,)
9
@2@.254.E3E3
3C(JU9(
AD
AC1=,
;
25333 ( 232 223
QUERY 2:
select salary from/select salary from /select distinct salary from / select distinct salary from
employees5 order by salary desc0 where rownumFP40 order by salary asc0 where rownumFP26
OUTPUT:
SALARY
24333
QUERY 3:
select salary from/select salary from /select distinct salary from / select distinct salary from
employees5 order by salary asc0 where rownumFP40 order by salary desc0 where rownumFP26
OUTPUT:
SALARY
4233
QUERY 4:
select ? from employees5 where rownumFPC6
OUTPUT:
EMPLO
YEE(I
D
*IRST(N
AME
LAST(N
AME EMAIL
P+ONE(N
UM)ER
+IRE(D
ATE
.O)(I
D
SALA
RY
COMMISSI
ON(PCT
MANA,E
R(ID
DEPARTM
ENT(ID
233 steven %ing I)9, @2@.254.D@BC
2C(JU9(
EC
A*1";
E
5D333 ( ( A3
232 9eena %ochhar
9I'C-
-A;
@2@.254.D@E 52(E"(EAA*1:" 2C333 ( 233 A3
235 .e! *ehaan
.*E-A
A9
@2@.254.D@BA
2C(JA9(
A4
A*1:" 2C333 ( 233 A3
234 Ale!ander -unold
A-U9'
.*
@A3.D54.D@BC
34(JA9(
A3
)T1";'
,
A333 ( 235 B3
23D Bruce Ernst BE;9T @A3.D54.D@BE
52(=A<(
A2
)T1";'
,
B333 ( 234 B3
23C *iana .orentM
*.';E9
TS
@A3.D54.@@BC
3C(FEB(
AA
)T1";'
,
D533 ( 234 B3
25D Iebin =ourgos
I='U;
,'
B@3.254.@54D
2B(9':(
AA
T1=A
9
@E33 ( 233 @3
QUERY 7:
select ? from employees5 minus select ? from employees5 where rownumFP /select count/?0 (@
from employees506
OUTPUT:
EMPL
OYEE(
ID
*IRST(N
AME
LAST(N
AME EMAIL
P+ONE(N
UM)ER
+IRE(D
ATE .O)(ID
SALA
RY
COMMISSI
ON(PCT
MANA,
ER(ID
DEPARTM
ENT(ID
533 Jennifer Lhalen
JL-A.
E9
@2@.254.DDDD
2C(E"(
EC
A*1ATDD33 ( 232 23
532 =ichael -artstein
=-A;T
TE
@2@.254.@@@@
2C(FEB(
AB
=I1=A924333 ( 233 53
535 "at Fay "FA< B34.254.BBBB
2C(AU,(
AC
=I1;E" B333 ( 532 53
53@ heliey -iggins
-),,)
9
@2@.254.E3E3
3C(JU9(
AD
AC1=,; 25333 ( 232 223
53B Lilliam ,ietM L,)ETS@2@.254.E2E2
3C(JU9(
AD
AC1ACC
'U9T
E433 ( 53@ 223
QUERY 8:
select department1name from departments left #oin employees5 on
departments.department1idPemployees5.department1id where employees5.department1id is
null6
OUTPUT:
DEPARTMENT(NAME
Contracting
QUERY 9:
select salary from/select salary from /select distinct salary from / select distinct salary from
employees5 order by salary desc0 where rownumFP40 order by salary desc0 where rownumFP46
OUTPUT:
SALARY
5D333
2C333
24333
QUERY ::
select salary from/select salary from /select distinct salary from / select distinct salary from
employees5 order by salary asc0 where rownumFP40 order by salary asc0 where rownumFP46
OUTPUT:
SALARY
5@33
5B33
4233
QUERY /;:
select salary from/select salary from /select distinct salary from / select distinct salary from
employees5 order by salary desc0 where rownumFPC0 order by salary asc0 where rownumFP26
OUTPUT:
SALARY
A333
RESULT:
Thus the s$l $ueries were performed on employee table and verified successfully.
EX.NO:
DATE:
QUESTION:
20elect no of employees #oined with respect to year and month from
employee table
50elect department,total salary with respect to a department from
employee table where total salary greater than E33333 order by
Total1alary descending
40 -ow can ) retrive all records of emp2 those should not present in emp5W
D0 Count the totalsal deptno wise where more than 5 employees e!ist.
@0 uppose there is annual salary information provided by emp table. -ow
to fetch monthly salary of each and every employeeW
B0 elect all record from emp table where deptno P23 or D3.
C0 elect all record from emp table where deptnoP43 and salG2@33.
E0 elect all record from emp where #ob not in A.E=A9 or C.E;I.
A0 elect all record from emp where ename in >B.AIE>,>C'TT>,>I)9,>and>F';*>.
230elect all records where ename starts with K+ and its lenth is B char.
AIM:
To perform s$l $ueries on employee table.
DESCRIPTION:
The *ata *efinition .anguage is used to create an ob#ect/e.g table0,alter the structure
of the table and also drop the ob#ect created. A table is a unit of storage that holds the data in
the form of rows and columns.
The *ata *efinition .anguage is used to
Create the table,
Alter the table,
Truncate the table,
*rop the table.
The *ata manipulation .anguage is used to insert an ob#ect,select is used to display fields and
delete to remove ob#ects inserted. A table is a unit of storage that holds the data in the form of
rows and columns.
The *ata manipulation .anguage is used to
)nsert
elect
Update
*elete.
QUERY /:
elect ? from employees5 where to1char/hire1date,><<<<>0 P >2AAA>6
OUTPUT:
EMPLO
YEE(I
D
*IRST(N
AME
LAST(N
AME EMAIL
P+ONE(N
UM)ER
+IRE(D
ATE
.O)(I
D
SALA
RY
COMMISSI
ON(PCT
MANA,E
R(ID
DEPARTM
ENT(ID
23C *iana .orentM
*.';E9
TS
@A3.D54.@@BC
3C(FEB(
AA
)T1";
',
D533 ( 234 B3
25D Iebin =ourgos
I='U;
,'
B@3.254.@54D
2B(9':(
AA
T1=A
9
@E33 ( 233 @3
2CE Iimberely ,rant
I,;A9
T
322.DD.2BDD.D
5A5B4
5D(=A<(
AA
A1;E
"
C333 3 2DA (
elect ? from employees5 where to1char/hire1date,>=on>0 P >Jan>6
EMPLO
YEE(I
D
*IRST(N
AME
LAST(N
AME EMAIL
P+ONE(N
UM)ER
+IRE(D
ATE
.O)(I
D
SALA
RY
COMMISSI
ON(PCT
MANA,E
R(ID
DEPARTM
ENT(ID
235 .e! *ehaan
.*E-A
A9
@2@.254.D@BA
2C(JA9(
A4
A*1:" 2C333 ( 233 A3
234 Ale!ander -unold
A-U9'
.*
@A3.D54.D@BC
34(JA9(
A3
)T1";'
,
A333 ( 235 B3
2D5 Curtis *avies
C*A:)E

B@3.252.5AAD
5A(JA9(
AC
T1C.E
;I
4233 ( 25D @3
2DA Eleni Slot%ey
ES.'T
IE<
322.DD.24DD.D
5A32E
5A(JA9(
33
A1=A
9
23@33 3 233 E3
QUERY 1:
selectdepartment1id, sum/salary0 from employees group by department1id having sum /salary0
GE3333 order by sum/salary0 desc6
OUTPUT:
no data found
QUERY 2:
create table employees4/E=".'<EE1)* number/230,F);T19A=E
varchar5/530,.AT19A=E varchar5/530,E=A). varchar5/530,"-'9E19U=BE;
varchar5/430,-);E1*ATE date,J'B1)* varchar5/530,A.A;<
number/530,C'==))'91"CT number/230,=A9A,E;1)*
number/230,*E"A;T=E9T1)* number/23006
desc employees46
OUTPUT:
Table Column Data Type Lent! P"e#$%$on S#ale P"$ma"y &ey Nullable De'ault Comment
E=".'<E
E4
E=".'<EE1)* 9umber ( 23 3 ( ( (
F);T19A=E :archar5 53 ( ( ( ( (
.AT19A=E :archar5 53 ( ( ( ( (
E=A). :archar5 53 ( ( ( ( (
"-'9E19U=BE; :archar5 43 ( ( ( ( (
-);E1*ATE *ate C ( ( ( ( (
J'B1)* :archar5 53 ( ( ( ( (
A.A;< 9umber ( 53 3 ( ( (

C'==))'91"C
T
9umber ( 23 3 ( ( (
=A9A,E;1)* 9umber ( 23 3 ( ( (
*E"A;T=E9T1)*9umber ( 23 3 ( ( (
insert into employees4 values/2DA,>%irthi>,>simbu>,>%irthii>,>325.DD.24DD.D5A32E>,>5A(=A;(
33>,>A1=A9>,23@33,.5,233,E306
2 row/s0 inserted.
insert into employees4 values/2DA,>Eleni>,>Slot%ey>,>ES.'TIE<>,>322.DD.24DD.D5A32E>,>5A(JA9(
33>,>A1=A9>,23@33,.5,233,E306
2 row/s0 inserted.
insert into employees4 values/2CD,>Ellen>,>Abel>,>EABE.>,>322.DD.2BDD.D5A5BC>,>22(=A<(
AB>,>A1;E">,22333,.4,2DA,E306
2 row/s0 inserted.
insert into employees4 values/233,>vic%y>,>%rish>,>vini>,>@2D.254.D@BC>,>2C(JA9(
EC>,>A*1";E>,5D33,null,null,A306
2 row/s0 inserted.
insert into employees4 values/233,>sindhu>,>#a>,>doc>,>@3D.254.D@BC>,>2C(=A;(
EC>,>A*1";E>,5D33,null,null,A306
2 row/s0 inserted.
insert into employees4 values/532,>=ichael>,>-artstein>,>=-A;TTE>,>@2@.254.@@@@>,>2C(FEB(
AB>,>=I1=A9>,24333,null,233,5306
2 row/s0 inserted.
insert into employees4 values/235,>.e!>,>*ehaan>,>.*E-AA9>,>@2@.254.D@BA>,>2C(JA9(
A4>,>A*1:">,2C333,null,233,A306
2 row/s0 inserted.
select ? from employees46
OUTPUT:
EMPLO
YEE(ID
*IRST(N
AME
LAST(N
AME EMAIL
P+ONE(N
UM)ER
+IRE(D
ATE
.O)(I
D
SALA
RY
COMMISSI
ON(PCT
MANA,E
R(ID
DEPARTM
ENT(ID
2DA Iirthi simbu %irthii
325.DD.24DD.D
5A32E
5A(=A;(
33
A1=A
9
23@33 3 233 E3
2DA Eleni Slot%ey
ES.'TI
E<
322.DD.24DD.D
5A32E
5A(JA9(
33
A1=A
9
23@33 3 233 E3
2CD Ellen Abel EABE.
322.DD.2BDD.D
5A5BC
22(=A<(
AB
A1;E
"
22333 3 2DA E3
233 :ic%y %rish vini @2D.254.D@BC
2C(JA9(
EC
A*1";
E
5D33 ( ( A3
233 sindhu #a doc @3D.254.D@BC
2C(=A;(
EC
A*1";
E
5D33 ( ( A3
532 =ichael -artstein
=-A;T
TE
@2@.254.@@@@
2C(FEB(
AB
=I1=
A9
24333 ( 233 53
235 .e! *ehaan
.*E-A
A9
@2@.254.D@BA
2C(JA9(
A4
A*1:" 2C333 ( 233 A3
elect ? from employees5 where first1name not in /elect first1name from employees406
OUTPUT:
EMPL
OYEE(
ID
*IRST(N
AME
LAST(N
AME EMAIL
P+ONE(N
UM)ER
+IRE(D
ATE .O)(ID
SALA
RY
COMMISSI
ON(PCT
MANA,
ER(ID
DEPARTM
ENT(ID
233 steven %ing I)9, @2@.254.D@BC
2C(JU9(
EC
A*1";E5D333 ( ( A3
232 9eena %ochhar
9I'C-
-A;
@2@.254.D@E
52(E"(
EA
A*1:" 2C333 ( 233 A3
234 Ale!ander -unold
A-U9'
.*
@A3.D54.D@BC
34(JA9(
A3
)T1";', A333 ( 235 B3
23D Bruce Ernst BE;9T@A3.D54.D@BE
52(=A<(
A2
)T1";', B333 ( 234 B3
23C *iana .orentM
*.';E
9TS
@A3.D54.@@BC
3C(FEB(
AA
)T1";', D533 ( 234 B3
25D Iebin =ourgos
I='U;
,'
B@3.254.@54D
2B(9':(
AA
T1=A9 @E33 ( 233 @3
2D2 Trenna ;a#s T;AJ B@3.252.E33A
2C('CT(
A@
T1C.E;
I
4@33 ( 25D @3
2D5 Curtis *avies
C*A:)E

B@3.252.5AAD
5A(JA9(
AC
T1C.E;
I
4233 ( 25D @3
2D4 ;andall =atos
;=AT'

B@3.252.5ECD
2@(=A;(
AE
T1C.E;
I
5B33 ( 25D @3
2DD "eter :argas
":A;,
A
B@3.252.533D
3A(JU.(
AE
T1C.E;
I
5@33 ( 25D @3
2CB Jonathon Taylor
JTA<.'
;
322.DD.2BDD.
D5A5B@
5D(=A;(
AE
A1;E" EB33 3 2DA E3
2CE Iimberely ,rant
I,;A9
T
322.DD.2BDD.
D5A5B4
5D(=A<(
AA
A1;E" C333 3 2DA (
533 Jennifer Lhalen
JL-A.E
9
@2@.254.DDDD
2C(E"(
EC
A*1ATDD33 ( 232 23
535 "at Fay "FA< B34.254.BBBB
2C(AU,(
AC
=I1;E" B333 ( 532 53
53@ heliey -iggins
-),,)
9
@2@.254.E3E3
3C(JU9(
AD
AC1=,; 25333 ( 232 223
53B Lilliam ,ietM L,)ETS @2@.254.E2E2
3C(JU9(
AD
AC1ACC
'U9T
E433 ( 53@ 223
535 "at Fay "FA< B34.254.BBBB
2C(AU,(
AC
=I1;E" B333 ( 532 53
QUERY 3:
select avg/salary0 from employees5 having count/employee1id0G2 group by department1id6
OUTPUT:
A-,5SALARY6
2A444.4444444444444444444444444444444444
A@33
232@3
4@33
23344.4444444444444444444444444444444444
BD33
QUERY 4:
select concat/first1name,last1name0as name,salary?25&25 as monthlysal from employees56
OUTPUT:
NAME MONT+LYSAL
teven%ing 5D333
9eena%ochhar 2C333
.e!*ehaan 2C333
Ale!ander-unold A333
BruceErnst B333
*iana.orentM D533
Iebin=ourgos @E33
Trenna;a#s 4@33
Curtis*avies 4233
;andall=atos 5B33
"eter:argas 5@33
EleniSlot%ey 23@33
EllenAbel 22333
JonathonTaylor EB33
Iimberely,rant C333
JenniferLhalen DD33
=ichael-artstein 24333
"atFay B333
heliey-iggins 25333
Lilliam,ietM E433
QUERY 7:
select ?from employees5 where department1idP23 '; department1idPD36
OUTPUT:
EMPLO
YEE(ID
*IRST(N
AME
LAST(N
AME
EMAI
L
P+ONE(N
UM)ER
+IRE(D
ATE
.O)(I
D
SALA
RY
COMMISSI
ON(PCT
MANA,E
R(ID
DEPARTM
ENT(ID
533 Jennifer Lhalen
JL-A.
E9
@2@.254.DDDD 2C(E"(EC
A*1A
T
DD33 ( 232 23
QUERY 8:
select ?from employees5 where department1idP43 '; salaryG2@336
OUTPUT:
EMPL
OYEE(
ID
*IRST(N
AME
LAST(N
AME EMAIL
P+ONE(N
UM)ER
+IRE(D
ATE .O)(ID
SALA
RY
COMMISSI
ON(PCT
MANA,
ER(ID
DEPARTM
ENT(ID
233 teven %ing I)9, @2@.254.D@BC
2C(JU9(
EC
A*1";E5D333 ( ( A3
232 9eena %ochhar
9I'C-
-A;
@2@.254.D@E
52(E"(
EA
A*1:" 2C333 ( 233 A3
235 .e! *ehaan
.*E-A
A9
@2@.254.D@BA
2C(JA9(
A4
A*1:" 2C333 ( 233 A3
234 Ale!ander -unold
A-U9'
.*
@A3.D54.D@BC
34(JA9(
A3
)T1";', A333 ( 235 B3
23D Bruce Ernst BE;9T@A3.D54.D@BE
52(=A<(
A2
)T1";', B333 ( 234 B3
23C *iana .orentM
*.';E
9TS
@A3.D54.@@BC
3C(FEB(
AA
)T1";', D533 ( 234 B3
25D Iebin =ourgos
I='U;
,'
B@3.254.@54D
2B(9':(
AA
T1=A9 @E33 ( 233 @3
2D2 Trenna ;a#s T;AJ B@3.252.E33A
2C('CT(
A@
T1C.E;
I
4@33 ( 25D @3
2D5 Curtis *avies
C*A:)E

B@3.252.5AAD
5A(JA9(
AC
T1C.E;
I
4233 ( 25D @3
2D4 ;andall =atos
;=AT'

B@3.252.5ECD
2@(=A;(
AE
T1C.E;
I
5B33 ( 25D @3
2DD "eter :argas
":A;,
A
B@3.252.533D
3A(JU.(
AE
T1C.E;
I
5@33 ( 25D @3
2DA Eleni Slot%ey
ES.'TI
E<
322.DD.24DD.
D5A32E
5A(JA9(
33
A1=A9 23@33 3 233 E3
2CD Ellen Abel EABE.
322.DD.2BDD.
D5A5BC
22(=A<(
AB
A1;E" 22333 3 2DA E3
2CB Jonathon Taylor
JTA<.'
;
322.DD.2BDD.
D5A5B@
5D(=A;(
AE
A1;E" EB33 3 2DA E3
2CE Iimberely ,rant
I,;A9
T
322.DD.2BDD.
D5A5B4
5D(=A<(
AA
A1;E" C333 3 2DA (
533 Jennifer Lhalen
JL-A.E
9
@2@.254.DDDD
2C(E"(
EC
A*1ATDD33 ( 232 23
532 =ichael -artstein
=-A;T
TE
@2@.254.@@@@
2C(FEB(
AB
=I1=A924333 ( 233 53
535 "at Fay "FA< B34.254.BBBB
2C(AU,(
AC
=I1;E" B333 ( 532 53
53@ heliey -iggins
-),,)
9
@2@.254.E3E3
3C(JU9(
AD
AC1=,; 25333 ( 232 223
53B Lilliam ,ietM L,)ETS @2@.254.E2E2
3C(JU9(
AD
AC1ACC
'U9T
E433 ( 53@ 223
QUERY 9:
select ?from employees5 where #ob1idP>T1=A9> or #ob1idP>T1C.E;I>6
OUTPUT:
EMPLO
YEE(I
D
*IRST(N
AME
LAST(N
AME EMAIL
P+ONE(N
UM)ER
+IRE(D
ATE
.O)(I
D
SALA
RY
COMMISSI
ON(PCT
MANA,E
R(ID
DEPARTM
ENT(ID
25D Iebin =ourgos
I='U;
,'
B@3.254.@54D
2B(9':(
AA
T1=A
9
@E33 ( 233 @3
2D2 Trenna ;a#s T;AJ B@3.252.E33A
2C('CT(
A@
T1C.E
;I
4@33 ( 25D @3
2D5 Curtis *avies
C*A:)E

B@3.252.5AAD
5A(JA9(
AC
T1C.E
;I
4233 ( 25D @3
2D4 ;andall =atos
;=AT'

B@3.252.5ECD
2@(=A;(
AE
T1C.E
;I
5B33 ( 25D @3
2DD "eter :argas
":A;,
A
B@3.252.533D 3A(JU.(AE
T1C.E
;I
5@33 ( 25D @3
QUERY ::
select ? from employees5 where last1name in/>bla%e>,>scott>,>%ing>,>ford>06
OUTPUT:
EMPLO
YEE(ID
*IRST(N
AME
LAST(N
AME
EMAI
L
P+ONE(N
UM)ER
+IRE(D
ATE
.O)(I
D
SALA
RY
COMMISSI
ON(PCT
MANA,E
R(ID
DEPARTME
NT(ID
233 steven Iing I)9,@2@.254.D@BC 2C(JU9(EC
A*1";
E
5D333 ( ( A3
QUERY /;:
select ?from employees5 where first1name li%e >sR> and length/first1name0PB6
OUTPUT:
EMPLO
YEE(ID
*IRST(N
AME
LAST(N
AME
EMAI
L
P+ONE(N
UM)ER
+IRE(D
ATE
.O)(I
D
SALA
RY
COMMISSI
ON(PCT
MANA,E
R(ID
DEPARTME
NT(ID
233 steven Iing I)9,@2@.254.D@BC 2C(JU9(EC
A*1";
E
5D333 ( ( A3
RESULT:
Thus the s$l $ueries were performed on employee table and verified successfully.
EX.NO:
DATE:
,$Ben t!e 'olloC$n "elat$on anD eEample Data:
Pa"tNumbe" De%#"$pt$on Suppl$e" Suppl$e"ADD"e%% P"$#e
23323 53 ,B *is% eagate Cuppertino, CA Y233
23323 53 ,B *is% )B= Armon%, 9< YA3
23553 5@B =B ;A= card Iensington an =ateo, CA Y553
23553 5@B =B ;A= card )B= Armon%, 9< Y5A3
23553 5@B =B ;A= card un =icrosystems "alo Alto, CA Y423
23DD3 2CV .C* =onitor )B= Armon%, 9< Y5,233

.ist the functinoal dependencies and 9ormaliMe this relation into BC9F.
AIM:
To list the functional dependencies and normaliMation.
ANS?ER:
Functional dependencies are7
"art9umber (G *escription
"art9umber, upplier (G "rice
upplier (G upplierAddress

29F7 uggest "art9umber, upplier as the %ey so we are in 29F

PART NUM)ER SUPPLIER
23323 eagate
23323 )B=
23553 Iensington
23553 )B=
23553 un =icrosystems
23DD3 )B=
59F7 Le have a partial %ey dependency in that upplier (G upplierAddress
so normaliMe7
;2/"art9umber, *escription, upplier, "rice0
PARTNUM)ER DESCRIPTION SUPPLIER PRICE
23323 53 ,B *is% eagate Y233
23323 53 ,B *is% )B= YA3
23553 5@B =B ;A= card Iensington Y553
23553 5@B =B ;A= card )B= Y5A3
23553 5@B =B ;A= card un =icrosystems Y423
23DD3 2CV .C* =onitor )B= Y5,233
"art9umber (G *escription
PARTNUM)ER DESCRIPTION
23323 53 ,B *is%
23323 53 ,B *is%
23553 5@B =B ;A= card
23553 5@B =B ;A= card
23553 5@B =B ;A= card
23DD3 2CV .C* =onitor
"art9umber, upplier (G "rice
PARTNUM)ER SUPPLIER PRICE
23323 eagate Y233
23323 )B= YA3
23553 Iensington Y553
23553 )B= Y5A3
23553 un =icrosystems Y423
23DD3 )B= Y5,233
;5/upplier, upplierAddress0
SUPPLIER SUPPLIERADDRESS
eagate Cuppertino, CA
)B= Armon%, 9<
Iensington an =ateo, CA
)B= Armon%, 9<
un =icrosystems "alo Alto, CA
)B= Armon%, 9<
upplier (G upplierAddress
SUPPLIER SUPPLIERADDRESS
eagate Cuppertino, CA
)B= Armon%, 9<
Iensington an =ateo, CA
)B= Armon%, 9<
un =icrosystems "alo Alto, CA
)B= Armon%, 9<
Le still have a problem with ;2 so normaliMe again7
;4 /"art9umber, upplier, "rice0
PARTNUM)ER SUPPLIER PRICE
23323 eagate Y233
23323 )B= YA3
23553 Iensington Y553
23553 )B= Y5A3
23553 un =icrosystems Y423
23DD3 )B= Y5,233
"art9umber, upplier (G "rice
PARTNUM)ER SUPPLIER PRICE
23323 eagate Y233
23323 )B= YA3
23553 Iensington Y553
23553 )B= Y5A3
23553 un =icrosystems Y423
23DD3 )B= Y5,233
;D /"art9umber, *escription0
PARTNUM)ER DESCRIPTION
23323 53 ,B *is%
23323 53 ,B *is%
23553 5@B =B ;A= card
23553 5@B =B ;A= card
23553 5@B =B ;A= card
23DD3 2CV .C* =onitor
"art9umber (G *escription
PARTNUM)ER DESCRIPTION
23323 53 ,B *is%
23323 53 ,B *is%
23553 5@B =B ;A= card
23553 5@B =B ;A= card
23553 5@B =B ;A= card
23DD3 2CV .C* =onitor

RESULT:
Thus to list the functional dependencies and normaliMation.
EX.NO:
DATE:
QUESTION:
Lrite the following inserts, deletes or updates in 8., using the university schema.
20 )ncrease the salary of each instructor in the Comp. ci. department by 23R.
50 *elete all courses that have never been offered /that is, do not occur in the section
relation0.
40)nsert every student whose tot cred attribute is greater than 233 as an instructor in the same
department, with a salary of Y23,333.
AIM:
To perform insertion,deletion and update in given tables.
DESCRIPTION:
The *ata *efinition .anguage is used to create an ob#ect/e.g table0,alter the structure
of the table and also drop the ob#ect created. A table is a unit of storage that holds the data in
the form of rows and columns.
The *ata *efinition .anguage is used to
Create the table,
Alter the table,
Truncate the table,
*rop the table.
The *ata manipulation .anguage is used to insert an ob#ect,select is used to display fields and
delete to remove ob#ects inserted. A table is a unit of storage that holds the data in the form of
rows and columns.
The *ata manipulation .anguage is used to
)nsert
elect
Update
*elete.
QUERY /:
update instructor set salary P salary ? 3.2 where dept1nameP>cse>6
@ row/s0 updated.
select ?from instructor6
OUTPUT:
ID NAME DEPT(NAME SALARY
25 :ino Cse 25333
2@ Iirthi Cse 22333
5@ :ic%y )t 2@3333
B *hivya Ete 243333
2A *heva Cse 2@33
22 sindhu Cse 2533
2E mano# Ece 23333
53 nandhini Cse 2@33
24 ri =ech 2E333
55 %ishor Civil 4D333
QUERY 1:
delete from course where course1id not in /select course1id from sections06
4 row/s0 deleted.
select ? from course6
OUTPUT:
COURSE(ID TITLE DEPT(NAME CREDITS
254 c Cse E.A
D@BB dbms Ete A
2B2E dotnet )t A.@
EAB bcme Civil E.@
QUERY 2:
insert into instructor select id,name,dept1name,salary from stus where tot1credG233 and
salaryP233336
@ row/s0 inserted.
select ? from instructor6
OUTPUT:
ID NAME DEPT(NAME SALARY
25 :ino cse 25333
2@ Iirthi cse 22333
5@ :ic%y it 2@3333
B dhivya ete 243333
2A dheva cse 2@33
22 sindhu cse 2533
2E mano# ece 23333
53 nandhini cse 2@33
24 ri mech 2E333
55 Iishor civil 4D333
CE gowtham it 23333
EE "riya auto 23333
CC vasanthi eee 23333
CA 9athiya ece 23333
A3 Iumar cse 23333
RESULT:
Thus to perform insertion,deletion and updation successfully.
EX.NO:
DATE:
QUESTION:
Consider the following table
A.E/A.E1)*, <EA;, ";'*UCT1)*, ";)CE06
";'*UCT/";'*UCT1)*, ";'*UCT19A=E06
20Consider the following $uery and rewrite for optimiMation The below $uery is to find the total
sales in each year and also the sales of product with id 23 in each year, Convert the below $uery
into single $uery
E.ECT T.<EA;, T.T'T1A., ".";'*1231A.
/
E.ECT <EA;, U=/";)CE0 T'T1A. F;'= A.E
,;'U" B< <EA;
0 T
.EFT 'UTE; J')9 /
E.ECT <EA;,
U=/";)CE0 ";'*1231A. F;'= A.E
L-E;E ";'*UCT1)* P 23
0 "
'9 /T.<EA; P ".<EA;06
50Ta%e a loo% at of your $uery, identify the redundant logic and then tune it.
E.ECT ".";'*UCT1)*, ".";'*UCT19A=E F;'= ";'*UCT " .EFT 'UTE; J')9
A.E
'9 /".";'*UCT1)* P .";'*UCT1)*0 L-E;E .A.E1)* ) 9U..6
Lrite the above $uery using 9'T EX)T and 9'T )9
40the below table is the #oin between the A.E and ";'*UCT table.
E.ECT .A.E1)*, .";'*UCT1)*, ".";'*UCT19A=E F;'= A.E
J')9 ";'*UCT "
'9 /.";'*UCT1)* P ".";'*UCT1)*0
Lrite the above $uery using correlated $uery
D0ta%e a loo% at of your $uery and write using EX)T or )9 operator
E.ECT .";'*UCT1)*, U=/";)CE0
F;'= A.E J')9 ";'*UCT "
'9 /.";'*UCT1)* P ".";'*UCT1)*0 ,;'U" B< .";'*UCT1)*6
AIM:
To write a $uery for given $uestion.
DESCRIPTION:
The *ata *efinition .anguage is used to create an ob#ect/e.g table0,alter the structure
of the table and also drop the ob#ect created. A table is a unit of storage that holds the data in
the form of rows and columns.
The *ata *efinition .anguage is used to
Create the table,
Alter the table,
Truncate the table,
*rop the table.
The *ata manipulation .anguage is used to insert an ob#ect,select is used to display fields and
delete to remove ob#ects inserted. A table is a unit of storage that holds the data in the form of
rows and columns.
The *ata manipulation .anguage is used to
)nsert
elect
Update
*elete.
QUERY /:
select year,
sum/case when product1id P 23
then price
else null
end 0 prod1231sal,
sum/sale1id0 tot1sal
from sales5
group by year6
OUTPUT:
YEAR PROD(/;(SAL TOT(SAL
2AAA ( 254B
2AAE ( 254@
2AA@ ( 5DC2
2AAD ( 2544
QUERY 1:
select p.product1id,p.product1name from products p where not e!ists/select 2 from sales5 s
where s.product1id Pp.product1id06
OUTPUT:
PRODUCT(ID PRODUCT(NAME
24 p@
2@ p5
2A pA
23 p2
2C pD
2E pE
2B p4
QUERY 2:
select s.sale1id,s.product1id,/select product1name from products p where p.product1id P
s.product1id0 from sales5 s6
OUTPUT:
SALE(I
D PRODUCT(ID
5SELECTPRODUCT(NAME*ROMPRODUCTSP?+EREP. PRODUCT(IDFS. P
RODUCT(ID6
2544 2EE (
254D 2EA (
254@ 2A3 (
254B 2DE (
254C 2@E (
QUERY 3:
select s.product1id, sum/price0 from sales5 s where product1id in/select product1id from
products p0 group by s.product1id6
OUTPUT:
no data found
RESULT:
Thus the s$l $ueries was e!ecuted successfully.
EX.NO:
DATE:
QUESTION:
20 Lrite a $uery to convert the following column into rows
ales7
customer1id product price
((((((((((((((((((((((((((((((((((((((
2 A 23
2 B 53
5 A 43
5 B D3
5 C @3
4 A B3
4 B C3
4 C E3
The rows of the VsalesV table needs to be converted into columns as shown below
Table Name: sales1rev
cutomer1id a1product b1product c1product
(((((((((((((((((((((((((((((((((((((((((
2 23 53
5 43 D3 @3
4 B3 C3 E3
50 *elete the customer1id P4.
40 Consider the the sales table structure shown below.
C;EATE TAB.E A.E
/
A.E1)* )9TE,E;,
";'*UCT1)* )9TE,E;,
<EA; )9TE,E;,
8uantity )9TE,E;,
";)CE )9TE,E;
06
a.Lrite a $uery to add new column ";'*UCT19A=E.
b.Lrite a $uery using BETLEE9 A9* operator.
c.Lrite a $uery to ort the data by <EA; in ascending order
d.Lrite a 8. $uery to find the minimum sales of a product without using the group by clause
AIM:
To write a $uery for given $uestion.
DESCRIPTION:
The *ata *efinition .anguage is used to create an ob#ect/e.g table0,alter the structure
of the table and also drop the ob#ect created. A table is a unit of storage that holds the data in
the form of rows and columns.
The *ata *efinition .anguage is used to
Create the table,
Alter the table,
Truncate the table,
*rop the table.
The *ata manipulation .anguage is used to insert an ob#ect,select is used to display fields and
delete to remove ob#ects inserted. A table is a unit of storage that holds the data in the form of
rows and columns.
The *ata manipulation .anguage is used to
)nsert
elect
Update
*elete.
QUERY /:
select ?from sales1rev unpivot Ze!clude nulls U include nulls[ /price for product in /a1product as
>a>, b1product as >b>, c1product1c as >c>006
OUTPUT:
CUSTOMER(ID A ) C
2 23 53 (
5 43 D3 @3
4 B3 C3 E3
QUERY 1:
delete from sales2 where customer1idP46
4 row/s0 deleted.
select ?from sales26
OUTPUT:
CUSTOMER(ID PRODUCT PRICE
2 A 23
2 B 53
5 A 43
5 B D3
5 C @3
QUERY 2:
create table saless/sale1id number,product1id number,year number,$uantity number,price
number06
Table created.
a6alter table saless add/product1name varchar/23006
Table altered.
insert into saless values/254,23,5324,@,2333,>oil>06
2 row/s0 inserted.
insert into saless values/D@B,5,532@,53,53333,>soap>06
2 row/s0 inserted.
insert into saless values/222,53,533@,C,2333,>colgate>06
2 row/s0 inserted.
insert into saless values/325,2@,533B,E,253,>rin>06
2 row/s0 inserted.
insert into saless values/25@,2B,532D,4,233,>ponds>06
2 row/s0 inserted.
insert into saless values/25C,2C,5325,@,23@3,>biscuit>06
2 row/s0 inserted.
insert into saless values/2D4,24,5332,5,2333,>surf>06
2 row/s0 inserted.
select ? from saless6
OUTPUT:
SALE(ID PRODUCT(ID YEAR QUANTITY PRICE PRODUCT(NAME
254 23 5324 @ 2333 'il
D@B 5 532@ 53 53333 oap
222 53 533@ C 2333 Colgate
25 2@ 533B E 253 ;in
25@ 2B 532D 4 233 "onds
25C 2C 5325 @ 23@3 Biscuit
2D4 24 5332 5 2333 urf
b6select ? from saless where year between 5323 and 53536
OUTPUT:
SALE(ID PRODUCT(ID YEAR QUANTITY PRICE PRODUCT(NAME
254 23 5324 @ 2333 'il
D@B 5 532@ 53 53333 oap
25@ 2B 532D 4 233 "onds
25C 2C 5325 @ 23@3 Biscuit
#6select ? from saless order by year asc6
OUTPUT:
SALE(ID PRODUCT(ID YEAR QUANTITY PRICE PRODUCT(NAME
2D4 24 5332 5 2333 surf
222 53 533@ C 2333 colgate
25 2@ 533B E 253 rin
25C 2C 5325 @ 23@3 biscuit
254 23 5324 @ 2333 oil
25@ 2B 532D 4 233 ponds
D@B 5 532@ 53 53333 soap
D6select product1id,year,$uantity from/select product1id,year,$uantity,row1number/0
over/partition by product1id order by $uantity asc0 min1sale1ran% from saless 0 where
min1sale1ran% P 26
OUTPUT:
PRODUCT(ID YEAR QUANTITY
5 532@ 53
23 5324 @
24 5332 5
2@ 533B E
2B 532D 4
2C 5325 @
53 533@ C


RESULT:
Thus the s$l $ueries was e!ecuted successfully.
EX.NO:
DATE:
QUESTION:
i0 .ist all the flight availabilities between Toronto /airport code is ><<S>0 and 9ew
<or% /airport code is >JFI>0. "lease display flight1no, origin, destinatin,
depature1time, and arrival1time. "lease sort them by flight1no.
ii0 .ist all customers who did not place any boo%ing. "lease display customer1id
only, and sort records by customer1id.
iii0 *isplay all customer>s first1name, last1name, phone1no /format li%e D2B(222(
55550 and email. "lease sort them by customer1id.
AIM:
To write a $uery for given $uestion.
DESCRIPTION:
The *ata *efinition .anguage is used to create an ob#ect/e.g table0,alter the structure
of the table and also drop the ob#ect created. A table is a unit of storage that holds the data in
the form of rows and columns.
The *ata *efinition .anguage is used to
Create the table,
Alter the table,
Truncate the table,
*rop the table.
The *ata manipulation .anguage is used to insert an ob#ect,select is used to display fields and
delete to remove ob#ects inserted. A table is a unit of storage that holds the data in the form of
rows and columns.
The *ata manipulation .anguage is used to
)nsert
elect
Update
*elete.
QUERY /:
select fno as flight1no,orig as origin,dest as destination,depttime
asdepature1ttime,arrtime as arrival1time
from flight1availability
where orig P >yyM> and dest P >#f%>
or orig P >#f%> and dest P >yyM>
order by fno6
OUTPUT:
no "oC% %ele#teD
QUERY 1:
select custid as customer1id
from customer
where custid not in /select distinct custid from boo%ing0
order by custid6
OUTPUT:
no "oC% %ele#teD
QUERY 2:
select c.custid as customer1id,
c.fname as first1name,
c.lname as last1name,
p.pcrtycodeUU>(>UUp.pareacodeUU>(>UUp.pnumber as phone1no,
e.email as email
from customer c
right #oin phone p on c.custid P p.custid
right #oin email e on c.custid P e.custid
order by c.custid6
OUTPUT:
no "oC% %ele#teD
RESULT:
Thus the set of $ueries has been performed successfully using the given tables.
EX.NO:
DATE:
QUESTION:
20 create a view >ordersview> from the table >orders> with following conditions
>c1cust1code> column must be created with C'U9T/*)T)9CT cust1code0 from the
>orders> table, >c1ag1code> column must be created with C'U9T/*)T)9CT
agent1code0 from the >orders> table, >c1ord1num> column must be created with
C'U9T/ord1num0 from the >orders> table, >avg1ord1amt> column must be created
with A:,/ord1amount0 from the >orders> table,>sum1amt> column must be created
with U=/ord1amount0 from the >orders> table,uni$ue >ord1date> must be within the
group.
50 To create a view >ordersview> by three tables >orders>, >customer> and > agents> with
following conditions =a= and =b= and =#= are the aliases of >orders> and >customer> and
>agents> table,>cust1code> of >orders> and >customer> table must be same, >agent1code> of
>orders> and >agents> table must be same.
40 create a view >agentview> with the columns >agent1name>, >wor%ing1area> and
>commission> of the table >agents> where >agent1name> and >commission> must be
arranged in descending order.
D0 create a view >agentview> as the table >agents> with following condition that
>cust1name> must begin with the letter >=>.
AIM:
To write a $uery for given $uestion.
DESCRIPTION:
The *ata *efinition .anguage is used to create an ob#ect/e.g table0,alter the structure
of the table and also drop the ob#ect created. A table is a unit of storage that holds the data in
the form of rows and columns.
The *ata *efinition .anguage is used to
Create the table,
Alter the table,
Truncate the table,
*rop the table.
The *ata manipulation .anguage is used to insert an ob#ect,select is used to display fields and
delete to remove ob#ects inserted. A table is a unit of storage that holds the data in the form of
rows and columns.
The *ata manipulation .anguage is used to
)nsert
elect
Update
*elete.
QUERY /:
create view ordersview /ord1dt,c1cust1code,c1ag1code,c1ord1num,avg1ord1amt,sum1amt0 as
select ord1dt,count/distinct cust1code0, count/distinct agent1code0,count/ord1num0,
avg/ord1amt0, sum/ord1amt0 from orders group by ord1dt6
:iew created.
desc ordersview6
Table Column Data Type Lent! P"e#$%$on S#ale P"$ma"y &ey Nullable De'ault Comment
';*E;:)
EL
';*1*T *ate C ( ( ( ( (
C1CUT1C'*E 9umber ( ( ( ( ( (
C1A,1C'*E 9umber ( ( ( ( ( (
C1';*19U= 9umber ( ( ( ( ( (

A:,1';*1A=
T
9umber ( ( ( ( ( (
U=1A=T 9umber ( ( ( ( ( (
select ? from ordersview6
OUTPUT:
ORD(DT C(CUST(CODE C(A,(CODE C(ORD(NUM A-,(ORD(AMT SUM(AMT
3E(JA9(3E 2 2 2 23333 23333
2@(A";(3E 2 2 2 43333 43333
43(AU,(3E 2 2 2 D@333 D@333
QUERY 1:
create view orderview as select ord1num, ord1amt, a.agent1code, agent1name, cust1name from
orders a, customer b, agent c where a.cust1codePb.cust1code and a.
agent1codePc.agent1code6
:iew created.
desc orderview6
OUTPUT:
Table Column Data Type Lent! P"e#$%$on S#ale P"$ma"y &ey Nullable De'ault Comment
';*E;:)E
L
';*19U= 9umber ( A 3 ( ( (
';*1A=T 9umber ( E 3 ( ( (
A,E9T1C'*E 9umber ( E 3 ( ( (
A,E9T19A=E :archar5 23 ( ( ( ( (
CUT19A=E :archar5 A ( ( ( ( (
select ? from orderview6
no data found
QUERY 2:
create view agentview as select agent1name, wor%ing1area, commission from agent order by
agent1name,commission desc6
:iew created.
desc agentview6
Table Column Data Type Lent! P"e#$%$on S#ale P"$ma"y &ey Nullable De'ault Comment
A,E9T:)
EL
A,E9T19A=E :archar5 23 ( ( ( ( (

L';I)9,1A;E
A
:archar5 A ( ( ( ( (
C'==))'9 9umber ( A 3 ( ( (
select ? from agentview6
OUTPUT:
A,ENT(NAME ?OR&IN,(AREA COMMISSION
Ale! .ondon 53
Alford 9ew<or% 5@
;aviIumar chennai 5@
ramsundhar banglore 23
QUERY 3:
create view agentsview as select ? from agent where agent1name li%e >mR>6
:iew created.
desc agentsview6
Table Column Data Type Lent! P"e#$%$on S#ale P"$ma"y &ey Nullable De'ault Comment
A,E9T:)
EL
A,E9T1C'*E 9umber ( A 3 ( ( (
A,E9T19A=E :archar5 23 ( ( ( ( (

L';I)9,1A;E
A
:archar5 A ( ( ( ( (
C'==))'9 9umber ( A 3 ( ( (
"-'9E19' 9umber ( A 3 ( ( (
select ? from agentsview6
OUTPUT:
no data found
RESULT:
Thus the set of $ueries has been performed successfully using the given tables.
EX NO:
DATE:
QUESTION:
2. .ist last name of all managers.
5. .ist last and first names of all customers.
4. ,ive a $uery that answers the $uestion V)s any of our employee also our customerVW
AIM:
To write s$l $ueries for the above $uestions.
DESCRIPTION:
The *ata *efinition .anguage is used to create an ob#ect/e.g table0,alter the structure
of the table and also drop the ob#ect created. A table is a unit of storage that holds the data in
the form of rows and columns.
The *ata *efinition .anguage is used to
Create the table,
Alter the table,
Truncate the table,
*rop the table.
QUERY/:
select .AT19A=E from employee where #obP>manager>6
LAST(NAME
Iing
Iochhar
-unold
Ernst
QUERY1:
select fname,lname from customer6
*NAME LNAME
sara nira
deeps %arthi%
aser uaisn
nin#i asdgh
opolil c!vb
QUERY2:
select fname,lname from customer where cus1namePe1name6
no data found6
RESULT:
Thus the s$l $ueries are was written and output verified successfully.
EX NO:
DATE:
QUESTION :
P"o"am to #!e#G C!et!e" $Ben numbe" $% A"m%t"on o" not.
AIM:
To chec% whether given number is Armstrong or not
SOLUTION:
*eclare
9 number6
number6
* number6
Begin
97P\n6
7P36
Lhile/nTP30
.oop
*PnR236
7Ps]/*?*?*06
97Pfloor/n&2306
End loop6
)f /*U"P0 then
*B=1output.put1line/Knumber is armstrong+06
Else
*B=1output.put1line/Knumber is not armstrong+06
End if6
End6
Lab
RESULT:
Thus the given number is armstrong or not is chec%ed and output verified successfully.
EX NO:
DATE:
QUESTION :
?"$te a p"o"am to '$nD la"e%t numbe" '"om t!e $Ben t!"ee numbe"%.
AIM:
To find largest number from the given three numbers.
SOLUTION:
*eclare
A number6
B number6
C number6
Begin
A7P\a6
B7P\b6
C7P\c6
)f a G b \\ aG c then
*bms1output.put1line/K A is big K06
Else
)f/ bGc \\ bG a 0 then
*bms1output.put1line/K B is big K06
Else
*bms1output.put1line/K C is big K06
End if6
End if6
End6
RESULT:
Thus the largest number from the given three numbers is done and output verified successfully.

Вам также может понравиться