You are on page 1of 6

Databare Management ayatem

an Xombli
ul(1 vit
tusth

(what
ate vitws 2 Explain
in Sal.

A vituw al 0 hos n wa
a u Kind
Viytual tabl.
Viewg Sel databare
the
in a veal table in
and COl umn a thty ame

wm mu mo
vtw by Selectinq fudi
c can oeate a

databae.
tablu bunt in thi
thu t a b l e oY
EPthv have all th mw
the tablt oY
Can
A v i tw
certafn Conditon.
basrcl on
Spethe we woA
and

wlll Leayn aloout


cTe atíng, dlele ting
Vew we
n thi8
Updatm9 viewg.

Sample Tabl
StudentDetailg

Name ADDRESS|
8-TD
Har | kolKata
AhghDuTgopus
PTatik Delh

phanraf BPha

Ram Rajas than


Student Mayka
TD Mam MaYkA AnE
Harg lo 19
9uYeRh So
Pratk 19
4
bhama 9S
|S Ram 8S 8
C.REA TTNG VIEWS

we con cTeate vfew uling cREATE VIE W Statement. A vleuo can he

coeated fom a Single table (multiple tabla

Syntax
CREATE VIEW vieuwname AS
SELECT Columni, column 0...
FROM table name
lama
WHERE cwncdithion vitw-nmi -> Vw for he vitw

tabu-na me- Nome d tu table

Cconditfon :tond'hon tv Select o

EXample
Cveattn9 view fTom a Sihgle table :

auery CREATE VIEW Detarlavtew AS


SELECT NAME, ADORESS
FROM StudentDetaits
WHERE 9-TD <Ss
To Se the data ?n tthe Viw

SELECT * FROM DelailEvtew;


utput: NAME ADDRES8

Harph Kol Kata

Abhsgh DurgapUA
pratik Delh

Dhanra B?h a
DELETINh VTEws
view.
vYew. we can
delete (GD
to delete
an Exikting
Sal allows uu
Stattmert,
DROP
a v?ew uing ttu
olop
SyntaxDROP VIEW vitw-nami
dtlete.
uwt want to
thl vfew whfth
View.name s Na me
MankAv?ew, we can do u's ai:
delete thu vêew
wLwant to
DROP V1EW maHKivituw
UPDATTN VTEws
ol to
to be Sat
Satis re ol
6fre
o n d i t t o n nudec
an ceYtatn
h PA not
met, u
conckhons
u thu
pd Cte a vrew, 4 any
the vrw.
we wull not be allowecl to updoute vitw Shouwd
Should.
cveate e vPe
the
t w
whith Ps ustd to
Stattment
).The SELECT
Clauuse,
ORDER By
not mclucle éroup By clauwe
havetu DTS TNCT Ku4wovol.
Statement ghould not
n SELECT
NOLl valuu,
all NoT
3 The VYew Shodd havt
uling nutid 9uLY'u
The Vituo Should not be cveoated
4
Complex quen'u.
bi C7eated om a gingle ta ble. 4 tu Vrewc
s)The Vrtw Shold
tablu then we uull not be allowed
Created uung mulhple
to update the Uit w,
EX wl can use CREATE 6REPLACE vIE 9tattment to
add 07 Temove flds fom a vitw,
Sytax: CREATE OR REPL ACE vrEw v?ew-na mu A3
SELEC T Columni, column 9,, . .
FROM tabll - name
OH ERE Conduthon
CREATE OR REPLACE VIEO
MaTkAvr'ew A8
8ELECT Stud e ntDetait &.NAME, StudentDetail&,
ADDRESR
StudentMayke.MARK&, Stud en HMaKs .A GE
FROM Stud entdetals, Stud ent Mauk
WHERE Student Detcul . NAME : StudtntM Ks NAME.

SELECT* FROM Maxktvreuw

Oudput
NAME ADDRESSMARKS AE
Hangkolkata 90 19
rattk Delhi
Dhanro Bha 9s

Ram Rajagthan 3

6)what ae tnogere ? Explai'n before and afttr tr99«78


uuith an Examblel

that th Syntem Executu autamahta


AtrtgqeY îs a Stotement
a a Sida effect a modifrcation to the databaal.

To dugn a trigger mechanigm, we mut mut two Teguutreme

Speufy Lohen a t'gger ?a to be Executtd, 7het ibroken f


nto an event that COuwU thi tMgger tu be dhec kedl and. a

Conditon that must be Stafied fo1 tn'ggev Execuhon to p

Speut the ach'onnto be taken whin the tgger Executa

Atnggety ?g a gtoved pyoceduu in dota bcue whreh


auto matrcatly invoku whunevt a 8pecial &vent in t the

databcLtC occut
a Dw Ps?nseytecA 9
can be
(nvoko nu
Examble A trggey Cevtar
table Columnu agl
when
table oY
Shecfed
nto a
bung updated.

Sytax Cye at Tn'g9er


ttgger- namej[before|aftJ

Prueyt Upoate | delete on

Ctablu- name

Catabn

Befor& and after Tm'ggar


the tn'gg*rng
Befove tnggevt run the tigqey action bcfoe
3tatemznt ' Tun.

achion aftr
te tnqgenng
Tun the trgge
After tggers
Statement i& un,

Cxamblu Studet Rebort Database.

Create trgey
Stud-manksbifore
INSERT
on
Sudent
fun Each o w

valueu (O, "ABcDE ', 20, &e,20,0, o),


mysql> inaert intu Student

Ok, i o w affecteol (o.09 Sec)


MySal> Select * fom Shudud
m d e loil a b0uf
? tXplar'n
ant Stvyed mced
ohat
Std1ed o e d u
can
thd
in SaL
codo
bmedun
in Sal Ph a lybe
Store many
time,
ond Can beuse
later ule callmg
Stored for ln tead
Executc
the que ry ,

ntid to
So,
oheneve you
Stored psuve
the
you can furt catl þrwcedunu
Stued

be p a e d
tovogh
vouuet t a n

Syntax: Cseattng a pwcedua,

CREATE PROCEDURE

USp pwductliz tAS8


BEIN
SELECT
pmduct-na

me igt-prite
FROM
procluction.prod.

UCtgORDER BY

productna
me'eNDS

The mopt impovkant þant 6 parameten . burameteá axe uie


to pals valuu to tthe proaure
w asu 3 d'fprent typu paramete»6, Ehuy ase

1N: Twy E the


Default þaram etev fov te þlu ye .
T4 aluunyt
ecva thi valuu from
calling prD9ram
Out Thit þoayameteY alwayA Sendu the va lun to tt
Callmg roarm.

You might also like