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

DBMS 3rd assignment Upto question 6

The document provides an overview of SQL (Structured Query Language), including its definition, characteristics, and advantages. It explains SQL's role in managing relational databases, its syntax, and various commands for data manipulation such as CREATE, INSERT, UPDATE, and DELETE. Additionally, it discusses aggregate functions, views, and stored procedures, along with examples of SQL queries and their outputs.

Uploaded by

YASH PHADOL
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

DBMS 3rd assignment Upto question 6

The document provides an overview of SQL (Structured Query Language), including its definition, characteristics, and advantages. It explains SQL's role in managing relational databases, its syntax, and various commands for data manipulation such as CREATE, INSERT, UPDATE, and DELETE. Additionally, it discusses aggregate functions, views, and stored procedures, along with examples of SQL queries and their outputs.

Uploaded by

YASH PHADOL
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Assignmunt No 3

Name Brajal D Goikuad


RolLne
:- A24 SEI
Subject DgMS
Define SQL & wite charecterist1 a & advantogegof
SQL
-SQL stands For Structued gey Longuag SQL
with a databaselt is the
Lswyed to commuaica te
stándard Language Lor latiOnal do tabas manage a
-eot Syskem.
SQLstateoments age wsed to penfoxnm diffeseot

updati0a adetlon of da a
S0Lis wed in vanous advance d Re latina databas
JNaaaqemaat System( RDBMs) Some Commaa ROBM
that
Acess Mictosoft SgLSeeSybaseloges cLe
SoL is developed biyIBM part f System
K proest-in 90.

ChastGkeeistis-of SL
- SQL is ao ANSI TSo slandardicemputer lasguage
for caating manipulatiag elata basuy
SLaldouws thuye toicaate updete de lete
etriee data fom a tette databae:
The tokans y syotax o sqL an ariegtked from
English commaa speech to leep the ccces barie
small possLh le Heace itis ey simp le.
to uan
AL the keyu ords 0+ sgu Cen be expe1e n any
Com binations of upper lowm case Charaeteat
mak no dlE Fercace whethew UPDATE, update
Update UpDate ie the keyuords
sQL is declanative longuage ioot a proca d ural

ny pouzfl longge
SQL Drks wit h dato bas pregramy lte. DB2
race, ms Access

Advaa+
High speed - SgLquemey can be wyed to fetieu
amounts. of gecads quicky 7 effrdsotly Irom a
databye
2

to anatherwit hout ooy probemi

3 Wedl clefined Standaxdy Exist - sQL dotabases ue


Aoag estabished gtanodard, DhËch is beiog adapted
by ANSÍ & ISO Whne as No-SL databae
do ot Caehes to any clec stasdad

4 SuppoTts object based pragramming sgL Suppests


anos objct coneoted prag3amming Can cepts which
makes it powen fut
2 wne t he syatax of the tollowlag common d of SQL
coeate table ia data base
Syata CREATE Table table name
-latatypeCsiz)
Coame 2 datatype(Siu
Colaame 3 datatycsie)

co loamen clata typc. csinu )

Lo

a) losrting valuein alL columnii


Syntax - Iheat ioto table-name

Lazetiog valuesin speeific calumas


Syotax laset into tabenama (coloame colaam2 - )
Valucy CVal1 , Val2 - )

e) lnseetiag teotds faom eaisting table iato ne


table
Sypte In set
Select colaamet colname2 Examold table
hee

To mate. so datab aye update


changes
Syotax Updato tabename st =
colname
nvalu Ewhee coadit ' o j

iv) Delete
As per quiiemets , the ecody from eis tíng
tabl caa be emove d uging de le te comman Dele te
Comncnd con have whe clause optlonally

Syata De Lete f0mtahle0an where Conditron)

peLetes the table stnue tuse alooc with eerds

syalap yatax Drop tak le tab eDam

Alter tateCadd aes columa)


Adey new column to kxisAia tahu
Syatax A1tr tohle table-name
Add cala£oe datqtype (sre) j

hte shot bote ao

Aggga te fcoactioa

-MAe SELECT The man


operatos
UNTON -combln esults fxem multp
& enores dupieade
UNION ALL 3ioular to UNLON, but
but kups duylicat:
tA INTER SECTpeturny only the commdo RCaTds
beween qune3
EXCEPT CNUS io Som data basey)
Petuo ncocd from the irstqeng that ae
preyeot in secande

) qqaeqate tunetions ín s L
Agprqate tunctions peafcrm calealation on 4
set ofvaluel k turn a Single eyul Commen
aggegat toactiang thclude 't
CouoC(Ounts the aunhex o rowS

AVGC)- calculoatex the average of numanValwy

Return the, higheyt yalu

4) What iS Vicw io SgL Explain wth excnpk


-’ i svitualLa ble contalaiag the

Statent exe suted Just Rike aeal tableiew


CoOAains Yows &columas
fusetiog HERE& JolN statments to alieo
Lhe data
the data Coming
Siag Le Lable The chang et ma dle ia
table get automaticaly nefleted in mqina
- Vitar is
Very
of dotabaye.
wyful anaintaing the Sceusty

Examiple itCoasider a bae Eable emplayhotay


following lata\

Empid empOame Sa loy Addres


EI kuoal Camp
Jay 7o00 7ilak Rogl
E3 Radhika Jooo Wore
E4 Sagar sB Road
ES Supiya 6700 GB Road

Now cOsider ws want to qiethis Eab le to


wsesbut dont waat to Shewhun Salone
Ehe employee lo that closk CanCaeate
vílw f m this ta ble cshich will coo tan oaly
the part
Show to wye

Empid emp-oame Ad dr
kunal Camp
Jay TÈlak Road
E3 Radita waje
Bagar SB Roa
ES }upnya
2. Aso in mul tluye System , iE Moy be posihe
that more Ehao one us mcy wcanL Lo updu te Ehe
data of sume Lable, Consider lG aurs A
want ko uplate, the enploy tobe, Io Such
will make changey in thei Gespecti
Vicws, & the spccti, changes
bas table automa tically

Explaun la the Suikca bu aggstgqat funetica.


Hggeqate func tio ns pea fr m caicula tcns
Single esult They ge comnmanly
Wsed cuith theGxup by clcse

de par t meot Sala


emp-id nam
Soo0o
Joho HR
IT t000o
2 Ale
Bo b "650 oo
SSo o O
bavJ
29
| Emma Saley
32
6 Sophio

Coun ting RouwS


Kmplayces
Elod the to tal numher of
tROM Emp
SELcCT (oUNT (*)AS total-employeey

total-employee
Data
Paga

2
Sum CO To tal Salay
Ftad the total Salag pald to au emploges
SELECI coUNT(1), AS tota! Salor EROM Empi

Result total-Saley
3SoO0.

3 AvG ()-Anrge Salay


find the alera'g salng F employs
SELCT AVG (Salan AsarageSplang FRom.
Emp le

Result acag L-Salog

4: Max U-Highest Sala


find the highest salsgameng cmpleyes
i seLECT P(Slag) As highest salaog
FROM Emp i

pesulk highest
70000
salag

5 mIN CO-LouestSalam
Flod the lowest Salog in the company
SELECT MINCSala AS loweat_Salar
FRom Erap)
salay
Wnte y explaun SgL functloo & proadus with
Sample examp
i)

Bgqgatt funstiong to pcforrm a caleutat ron oo


a set OB Valwe oe tus a síogle vaue. Vguay
CoUNT)
Diffeatat types of agase qa kete functioni i-,
t Mia ()- This function eturSmalLest valu Brom
Speerfied coluno of the table

2 Nlax Ch Thus func tion oeura qrtateyt valus Foa


specificd columo ot the table

select maxcsal) fxam emp)

2 Suom C)i Thi, fuac tioo eturn Sum of al values

Select Sum (sal) Prom emp j

Avgt This tunc tloa rtucd ayeage ot al the


iyaluey of speetid colua oh the ta ble

queny- elect vg (sat) from cmp '


Lcte

S. Çouot C) i- ThËs function oetury


totalAumhee
of valus ot specificdcolumaaf tadl.

Queny
) Bu t io Fuac tiong
Bult n fuactiun. nothiog hut Ehe fuac Libng.
which ane pre- de ined by S

Rathe than aggregots func tiong thee as Some

1 PoWER Cm)i To fiod nth Pasc to thenunbe

Qutput 16
2 >
ABSC) lt etumy the absoluto va lue

SQL Select abs C-Is) f0mdual

6utpute 1s

3. RoUND (Oi- E wl| ound up m upto th digit

SQL> Select gound e t (loo"256,2 ) from dua l

Outpu tr- (oo25


4 SQRTTo find
Squam rook f qieo numbey
SQLs Seleet Sqy t (2S) frm due l')

QutpuE:-5

5 GREATE ST (expLicxpexpn) etwrny


Rxpessiong
thegr
greatest

SQLSUect qrcateyt45. from duol)

s LEA ST CexpIe 2expn) turOs the owest

Stoog fuac tiong


. LohNEB (Strlaq) i fEumg the Stinq í lowriye

SQL select touer CRHOENlx) frm duolJ

output phacx
2- UpPER CSnng)-netumy the senng fn upperlcuye3
SQLs dect uppe (" phoeni) from dua')
Output PHoENX

3 NITAP( StrËng -To conrert firs t lett of cah


word n copital letLea

toitcop
SeL Seleet pper Cename)}rom emp

padded to ung Lh nwith the chanete speetfred


nchar 2

SQLs select lpad ("Phoeoiy lo '* ) fomdeali

padded to leng th ciith the cbane tem


speettis d in char2

outputí Phocaiy t

(. LTIM CStnnghom) emeve, chanee tes fva


Lhe' efE (heginung of the seming

{4OENLX
De

callin the pOed


CALL update Salamy
4 Pocedue to Dele te qn Employee -
Ths ereedue -employee csd based

DELMTER//
CREAIe PROCEDURE DeeteEmploy« CIN emp-jd INT
2EGIN
DELETE EROM Eomployes wHeRe emp-id emp i
END /

callig theProeduei

q)what is bogge
Eniggee ? Expla'n tngg wit h Sutohe
example.

You might also like