Dbms Lab Manual Regulation 2013

238
VALLIAMMAI ENGINEERING COLLEGE  SRM Nagar, Kattankulathur-603 202, Kancheepuram District, Tamil nadu (!!iliat ed t" nna #ni$ersit%, &hennai' Department of INFORMA TION TECHNOLOGY DBMS LAB MANUA L Prepared by Mr.R.Senthil ) *+, Dept "! T, ./& Subject Code & Name : T632  D1MS a Year / Semester  :  4  egree & Branch  : B.Tech – IT

Transcript of Dbms Lab Manual Regulation 2013

Page 1: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 1/238

VALLIAMMAI ENGINEERING COLLEGE  SRM Nagar, Kattankulathur-603 202, Kancheepuram District, Tamilnadu

(!!iliated t" nna #ni$ersit%, &hennai'

Department of

INFORMATION TECHNOLOGY 

DBMS LAB MANUALPrepared by

Mr.R.Senthil) *+,

Dept "! T,

./&

Subject Code & Name: T632 – D1MS a

Year / Semester   :  4

  egree & Branch   : B.Tech – IT

Page 2: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 2/238

(s )er nna #ni$ersit% S%llaus #nder 203 Regulati"ns'

SYLLABUS

(&"mm"n t" n!"rmati"n Techn"l"g% 5 &"mputer Science /ngineering'

&reati"n "! a dataase and riting S7 8ueries t" retrie$e in!"rmati"n !r"m the dataase

2 )er!"rming nserti"n, Deleti"n, M"di!%ing, ltering, #pdating and .ieing rec"rds ased "n c"nditi"ns3 &reati"n "! .ies, S%n"n%ms, Se8uence, nde9es, Sa$e p"int

: &reating an /mpl"%ee dataase t" set $ari"us c"nstraints

; &reating relati"nship eteen the dataases

6 Stud% "! )4S7 l"ck

< =rite a )4S7 l"ck t" satis!% s"me c"nditi"ns % accepting input !r"m the user

> =rite a )4S7 l"ck that handles all t%pes "! e9cepti"ns

? &reati"n "! )r"cedures

0 &reati"n "! dataase triggers and !uncti"ns

Mini pr"@ect (pplicati"n De$el"pment using +racle4 M%s8l '

a' n$ent"r% &"ntr"l S%stem

 ' Material Re8uirement )r"cessing

c' A"spital Management S%stem

d' Raila% Reser$ati"n S%stem

e' )ers"nal n!"rmati"n S%stem

!' =e 1ased #ser denti!icati"n S%stem

g' Timetale Management S%stem

h' A"tel Management S%stem

LAB EQUIPMENTS

Aardare and S"!tare re8uired !"r a atch "! 30 studentsB

Hardware:30 )ers"nal &"mputers

Software:

Front end B .14.& CC4. "r /8ui$alent

Back end B +racle 4 S7 4 M%S74 )"stress 4 D12 "r /8ui$alent

Platform B =ind"s 2000 )r"!essi"nal4E)

+racle ser$er c"uld e l"aded and can e c"nnected !r"m indi$idual )&s

Page 3: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 3/238

OBJECT!ES:

The "t#dent "ho#ld $e made to:

• earn t" create and use a dataase

• 1e !amiliariFed ith a 8uer% language

• Aa$e hands "n e9perience "n DD &"mmands

• Aa$e a g""d understanding "! DM &"mmands and D& c"mmands

• GamiliariFe ad$anced S7 8ueries

• 1e /9p"sed t" di!!erent applicati"ns

O%TCOMES:

&t the end of the co#r"e' the "t#dent "ho#ld $e a$le to:

• Design and implement a dataase schema !"r a gi$en pr"lem-d"main

• )"pulate and 8uer% a dataase

• &reate and maintain tales using )4S7

• )repare rep"rts

REFERE(CE:sp"ken-tut"rial"rg

GENERAL INSTRUCTIONS FOR LABORATORY CLASSES

)O*S

• =ith"ut )ri"r permissi"n d" n"t enter int" the a"rat"r%

• =hile entering int" the 1 students sh"uld ear their D cards• The Students sh"uld c"me ith pr"per dress c"de

• Students sh"uld sign in the +N R/ST/R e!"re entering int" the la"rat"r%

• Students sh"uld c"me ith "ser$ati"n, rec"rd n"te, class n"tes, and la rele$ant ""k t" the la"rat"r%

• Students sh"uld maintain silence inside the la"rat"r%

• !ter c"mpleting the la"rat"r% e9ercise, make sure t" shutd"n the s%stem pr"perl%

)O(T*S

• Students ringing the ags inside the la"rat"r%

Students earing slippers insides the la"rat"r%• Students using the c"mputers in an impr"per a%

• Students scriling "n the desk and mishandling the chairs

• Students using m"ile ph"nes inside the la"rat"r%

• Students making n"ise inside the la"rat"r%

(TRO)%CTO( TO S+,

S+,B

Page 4: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 4/238

Structured 8uer% language pr"n"unced as (S/7#/' This language is used t" c"mmunicate t" "racle

dataase

)ata$a"e Mana-ement S"tem /)BMS0B

t is a s"!tare it helps t" manage the dataase management s%stem sh"uld ale t" per!"rm the

!"ll"ing acti$ities $er% easil%

nserting the ne data

2 #pdating the e9iting data

3 Deleting unnecessar% data

: Retrie$ing the re8uire data

• dataase al"ng ith the s"!tare hich helps t" manage The dataase is called dataase

management s%stem (D1MS'

• D1MS hich is ased "n relati"nal the"r% is called as relati"nal dataase management s%stem

E1am2le" of R)BMSB

+R&/

2 S7 S/R./R

3 D12

: MHS7

; SH1S/

6 T/R DT

< MS &&/SS

S+, Command"

The S7 language is sudi$ided acc"rding t" their !uncti"ns as !"ll"s

)), 3 )ata )efinition ,an-#a-e

• )M, 3 )ata Mani2#lation ,an-#a-e

• )R,4)+, - )ata Retrie5al ,an-#a-e 4 )ata +#er ,an-#a-e

• )C,0 3 )ata Control ,an-#a-e

• TC,0 3 Tran"action Control

)ata )efinition ,an-#a-e /)),0:

Page 5: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 5/238

Data De!initi"n anguage (DD' "r Schema De!initi"n anguage, statements are used t" de!ine the dataase

structure "r schema

• CRE&TE - t" create "@ects in the dataase

• &,TER  - alters the structure "! the dataase

• )ROP - delete "@ects !r"m the dataase

• TR%(C&TE - rem"$e all rec"rds !r"m a tale, including all spaces all"cated !"r the rec"rds are rem"$ed

• COMME(T - add c"mments t" the data dicti"nar%

• RE(&ME - rename an "@ect

)ata Mani2#lation ,an-#a-e /)M,0:

Data Manipulati"n anguage (DM' statements are used !"r managing data ithin schema "@ects

• (SERT - insert data int" a tale

• %P)&TE - updates e9isting data ithin a tale

• )E,ETE - deletes all rec"rds !r"m a tale, the space !"r the rec"rds remain

• MER6E 3 %PSERT "perati"n (insert "r update'

• C&,, - call a )4S7 "r a$a supr"gram

• E7P,&( P,&( - e9plain access path t" data

• ,OC8 T&B,E - c"ntr"l c"ncurrenc%

)ata Retrie5al ,an-#a-e 4 )ata +#er ,an-#a-e /)R,4)+,0:

• SE,ECT - retrie$e data !r"m the a dataase

)ata Control ,an-#a-e /)C,0:

)ata Control ,an-#a-e (D&' statements S"me e9amplesB

• 6R&(T - gi$es userIs access pri$ileges t" dataase

• RE!O8E - ithdra access pri$ileges gi$en ith the RNT c"mmand

Tran"action Control /TC,0:

Transacti"n &"ntr"l (T&' statements are used t" manage the changes made % DM statements t all"s

statements t" e gr"uped t"gether int" l"gical transacti"ns

• COMMT 3 sa$e "rk d"ne

• S&!EPO(T - identi!% a p"int in a transacti"n t" hich %"u can later r"ll ack 

• RO,,B&C8  - rest"re dataase t" "riginal since the last &+MMT

• SET TR&(S&CTO( - &hange transacti"n "pti"ns like is"lati"n le$el and hat r"llack segment t" use

Page 6: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 6/238

 Fiq: SQL Architecture:

R#le":

+racle reser$ed "rds cann"t e used

2 #ndersc"re, numerals, letters are all"ed ut n"t lank space

3 Ma9imum length !"r the tale name is 30 characters

: T" di!!erent tales sh"uld n"t ha$e same name

; =e sh"uld speci!% a uni8ue c"lumn name

6 =e sh"uld speci!% pr"per data t%pe al"ng ith idth

< =e can include Jn"t null c"nditi"n hen needed 1% de!ault it is Lnull

> t is a c"mmand ased language

? t is n"t case sensiti$e

0 /$er% c"mmand sh"uld end ith L

/$er% c"mmand starts ith J$er

2 t is similar t" /nglish This language is de$el"ped in the %ear ?<2 Mr&+DD, % 1M

de$el"ped % J1M

Page 7: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 7/238

WORDS TO REMEMBER

This appendi9 lists "rds that ha$e a special meaning t" +racle /ach "rd pla%s a speci!ic r"le in the c"nte9t in hich it appears G"

e9ample, in an NS/RT statement, the reser$ed "rd NT+ intr"duces the tales t" hich r"s ill e added 1ut, in a G/T&A "r S//&T

statement, the reser$ed "rd NT+ intr"duces the "utput h"st $ariales t" hich c"lumn $alues ill e assigned

Oracle Re"er5ed 9ord"

The !"ll"ing "rds are reser$ed % +racle That is, the% ha$e a special meaning t" +racle and s" cann"t e rede!ined G"r this

reas"n, %"u cann"t use them t" name dataase "@ects such as c"lumns, tales, "r inde9es

&&/SS &+MM/NT G+T S +)T+N STRT #N+N

DD &+M)R/SS G+R /./ +R S//&T #N7#/

&+NN/&T GR+M K/ +RD/R S/SS+N #)DT/

T/R &R/T/ RNT +&K )&TGR// S/T #S/R  

ND &#RR/NT R+#) +N )R+R SAR/ .DT/

NH DT/ A.N ME/ET/NTS )R.//S SO/ .#/S

RRH/N D/&M D/NTG/D MN#S )#1& SMNT .R&AR  

S D/G#T MM/DT/ M+D/ R= S71#G .R&AR2

S& D//T/ N N+TG+#ND R/NM/ S#&&/SSG# ./=

#DT D/S& N&R/M/NT N+=T R/S+#R&/ SHN+NHM =A/N/./R  

1/T=//N DSTN&T ND/E N# R/.+K/ SHSDT/ =A/R/1H DR+) NT N#M1/R R+= T1/ =TA

&AR /S/ NS/RT +G R+=D TA/N

&A/&K /E&#S./ NT//R +GGN/ R+=1/ T+

&#ST/R /ESTS NT/RS/&T +N R+=N#M TR/R  

&+#MN G/ NT+ +NN/ R+=S #D

Oracle 8eword"

The !"ll"ing "rds als" ha$e a special meaning t" +racle ut are n"t reser$ed "rds and s" can e rede!ined A"e$er, s"me might e$entual

 ec"me reser$ed "rds

DMN &+#NT G+R/N MN/ET/NTS )R/&S+N S7/RR+R  

GT/R &#RS+R G+RTRN MN.#/ )RMRH S7STT/

+&T/ &H&/ G+#ND M+D#/ )R.T/ STT/M/NTPD

NHO/ DT1S/ G#N&T+N M+#NT )R+&/D#R/ STTST&S

R&A./ DTG/ + N/ET )R+G/ ST+)

R&A./+ D1 +T+ N/= 7#+T ST+R/

#TA+ROT+N D/& R+#)S N+R&A./+ R/D S#M

. D/&R/ N&#DN N+&&A/ R/ S=T&A

1&K#) DS1/ ND&T+R N+&H&/ R/&+./R SHST/M

1/N DSM+#NT NTRNS N+ME.#/ R/G/R/N&/S T1/S

1/&+M/ D+#1/ NSTN&/ N+MN.#/ R/G/R/N&N T1/S)&/

1/G+R/ D#M) NT N+N/ R/S/T+S T/M)+RRH

1+&K /&A K/H N++RD/R R/STR&T/D TAR/D

1+DH /N1/ N#/ N+R/S/T+S R/#S/ TM/&&A/ /ND H/R N+RM R+/ TR&N

&N&/ /S&)/ NK N+S+RT R+/S TRNS&T+N

&S&D/ /./NTS STS N#M/R& R+1&K TR/RS

&AN/ /E&/)T +G/ +GG S./)+NT TR#N&T/

&AR&T/R /E&/)T+NS MN/ +D S&A/M #ND/R  

&A/&K)+NT /E/& MN# +NH S&N #NMT/D

&+S/ /E)N ME +)/N S/&T+N #NT

&+1+ /E/&#T/ MEDTG/S +)TM S/M/NT #S/

&+MMT /ET/NT MENSTN&/S +=N S/7#/N&/ #SN

&+M)/ /ET/RNH ME+G/S )&K/ SAR/D =A/N

&+NSTRNT G/T&A ME+AST+RH )R/ SN)SA+T =RT/

Page 8: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 8/238

&+NSTRNTS G#SA ME+M/M1/RS )&TN&R/S/ S+M/ =+RK  

&+NT/NTS GR//ST METRNS )&T#S/D S+RT

&+NTN#/ GR//STS ME.#/ )N S7

&+NTR+G/ G+R&/ MN ) S7&+D/

P,4S+, Re"er5ed 9ord"

The !"ll"ing )4S7 ke%"rds ma% re8uire special treatment hen used in emedded S7 statements

1+RT &#ST/R D//T/ A.N N# R/S+#R&/ T1/

&&/)T &#ST/RS D/T D/NTG/D N#M1/R R/T#RN T1/S

&&/SS &+#TA D/S& G N#M1/RP1S/ R/./RS/ TSK  

DD &+#MNS DTS N +G R/.+K/ T/RMNT/

&+MMT DS)+S/ ND/E +N R+1&K TA/N

T/R &+M)R/SS DSTN&T ND/E/S +)/N R+=D T+

ND &+NN/&T D+ ND&T+R +)T+N R+=1/ TR#/

NH &+NSTNT DR+) NS/RT +R R+=N#M TH)/

RRH &+#NT /S/ NT//R +RD/R R+=TH)/ #N+N

RRH/N &RSA /SG NT/RS/&T +TA/RS R#N #N7#/

S &R/T/ /ND NT+ +#T S./)+NT #)DT/

S& &#RR/NT /NTRH S )&K/ S&A/M #S/

SS/RT &#RR. /E&/)T+N /./ )RTT+N S//&T .#/S

SSN &#RS+R /E&/)T+NPNT K/ )&TGR// S/)RT/ .R&AR  

T DT1S/ /ESTS MT/D )+ST./ S/T .R&AR2

#TA+ROT+N DTP1S/ /ET ++) )RM SO/ .RN&/

. DT/ GS/ ME )R+R SMNT ./=

1S/PT1/ D1 G/T&A MN )R.T/ S)&/ ./=S

1/N D/1#+GG G+T MN#S )R+&/D#R/ S7 =A/N

1/T=//N D/1#+N G+R MS1/ )#1& S7&+D/ =A/R/

1NRHPNT//R D/&R/ G+RM M+D RS/ S7/RRM =A/

1+DH D/&M GR+M M+D/ RN/ STRT =TA

1++/N D/G#T G#N&T+N NT#R R/ STT/M/NT =+RK  

1H &A/&K /N/R& N/= R/&+RD STDD/. E+R  

&S/ &+S/ +T+ N/ET. R//S/ S#1TH)/

&AR D/GNT+N RNT N+&+M)R/SS R/MR S#M&ARP1S/ D/H R+#) N+T R/NM/ T1#TA

Oracle Re"er5ed (ame"2ace"

&"ntains a list "! namespaces that are reser$ed % +racle The initial characters "! !uncti"n names in +racle liraries are restricted t"

the character strings in this list 1ecause "! p"tential name c"n!licts, use !uncti"n names that d" n"t egin ith these characters

G"r e9ample, the S7QNet Transparent Net"rk Ser$ice !uncti"ns all egin ith the characters NS, s" %"u need t" a$"id naming !uncti"ns

that egin ith NS

(ame"2ace ,i$rar

+ +& !uncti"ns

S !uncti"n names !r"m S71 and s%stem-dependent liraries

E e9ternal !uncti"ns !"r E applicati"ns "nl%

/N K) N N& ND N NM NR NS NT NO TT& #) nternal !uncti"ns

S+, O2erator"

&n "perat"r is a reser$ed "rd "r a character used primaril% in an S7 statementIs =A/R/ clause t" per!"rm

"perati"n(s', such as c"mparis"ns and arithmetic "perati"ns +perat"rs are used t" speci!% c"nditi"ns in an S7

statement and t" ser$e as c"n@uncti"ns !"r multiple c"nditi"ns in a statement

• rithmetic "perat"rs

• &"mparis"n "perat"rs

Page 9: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 9/238

• "gical "perat"rs

• +perat"rs used t" negate c"nditi"n

&rithmetic o2erator"

ssume $ariale a h"lds 0 and $ariale h"lds 20, thenBOperator Description Example

+ Addition - Adds values on either side of the operator a + b will give 30

- Subtraction - Subtracts right hand operand fro left hand operand a - b will give -!0

" #ultiplication - #ultiplies values on either side of the operator a " b will give $00

% &ivision - &ivides left hand operand b' right hand operand b % a will give $

( #odulus - &ivides left hand operand b' right hand operand and returns reainder b ( a will give 0

Com2ari"on o2erator"

O2erator )e"cri2tion E1am2le

&hecks i! the $alues "! t" "perands are e8ual "r n"t, i! %es then c"nditi"n ec"mes true (a ' is n"t

true

&hecks i! the $alues "! t" "perands are e8ual "r n"t, i! $alues are n"t e8ual then c"nditi"n ec"mes true (a ' is true

UV &hecks i! the $alues "! t" "perands are e8ual "r n"t, i! $alues are n"t e8ual then c"nditi"n ec"mes true (a UV ' is true

V &hecks i! the $alue "! le!t "perand is greater than the $alue "! right "perand, i! %es then c"nditi"n ec"mes

true

(a V ' is n"t

trueU &hecks i! the $alue "! le!t "perand is less than the $alue "! right "perand, i! %es then c"nditi"n ec"mes true (a U ' is true

V &hecks i! the $alue "! le!t "perand is greater than "r e8ual t" the $alue "! right "perand, i! %es then c"nditi"n

 ec"mes true

(a V ' is n"t

true

U &hecks i! the $alue "! le!t "perand is less than "r e8ual t" the $alue "! right "perand, i! %es then c"nditi"n

 ec"mes true

(a U ' is true

U &hecks i! the $alue "! le!t "perand is n"t less than the $alue "! right "perand, i! %es then c"nditi"n ec"mestrue

(a U ' is !alse

V &hecks i! the $alue "! le!t "perand is n"t greater than the $alue "! right "perand, i! %es then c"nditi"n ec"mes true

(a V ' is true

,o-ical o2erator"

O2erator )e"cri2tion

The "perat"r is used t" c"mpare a $alue t" all $alues in an"ther $alue set

ND The ND "perat"r all"s the e9istence "! multiple c"nditi"ns in an S7 statementIs =A/R/ clause

NH The NH "perat"r is used t" c"mpare a $alue t" an% applicale $alue in the list acc"rding t" the c"nditi"n

1/T=//N The 1/T=//N "perat"r is used t" search !"r $alues that are ithin a set "! $alues, gi$en the minimum $alue and the ma9imum $alue

/ESTS The /ESTS "perat"r is used t" search !"r the presence "! a r" in a speci!ied tale that meets certain criteria

N The N "perat"r is used t" c"mpare a $alue t" a list "! literal $alues that ha$e een speci!ied

K/ The K/ "perat"r is used t" c"mpare a $alue t" similar $alues using ildcard "perat"rs

 N+T The N+T "perat"r re$erses the meaning "! the l"gical "perat"r ith hich it is used /gB N+T /ESTS, N+T 1/T=//N, N+T N, et

+R The +R "perat"r is used t" c"mine multiple c"nditi"ns in an S7 statementIs =A/R/ clause

S N# The N# "perat"r is used t" c"mpare a $alue ith a N# $alue

#N7#/ The #N7#/ "perat"r searches e$er% r" "! a speci!ied tale !"r uni8ueness (n" duplicates'

SQL Functions

SQL has many bui!"in #unc!i$ns #$r per#$rmin% cacua!i$ns $n da!a.

S+, &--re-ate F#nction"

S7 aggregate !uncti"ns return a single $alue, calculated !r"m $alues in a c"lumn

• &'()* " +e!urns !he a,era%e ,aue

• -/0T)* " +e!urns !he number $# r$1s

Page 10: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 10/238

• I+ST)* " +e!urns !he rs! ,aue

• L&ST)* " +e!urns !he as! ,aue

• &)* " +e!urns !he ar%es! ,aue

• I0)* " +e!urns !he smaes! ,aue

• S/)* " +e!urns !he sum

S+, Scalar f#nction"

S7 scalar !uncti"ns return a single $alue, ased "n the input $alue

• /-&S)* " -$n,er!s a ed !$ upper case

• L-&S)* " -$n,er!s a ed !$ $1er case

• I)* " 9!rac! charac!ers #r$m a !e9! ed

• L0)* " +e!urns !he en%!h $# a !e9! ed

• +/0)* " +$unds a numeric ed !$ !he number $# decimas specied

• 0:)* " +e!urns !he curren! sys!em da!e and !ime

• +&T)* " $rma!s h$1 a ed is !$ be dispayed

S+, Strin- F#nction"S7 string !uncti"ns are used primaril% !"r string manipulati"n The !"ll"ing tale details the imp"rtant string

!uncti"nsB(ame )e"cri2tion

;

Page 11: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 11/238

S&(' Returns numeric $alue "! le!t-m"st character 

1N(' Returns a string representati"n "! the argument

1TP/NTA(' Returns length "! argument in its

&ARP/NTA(' Returns numer "! characters in argument

&AR(' Returns the character !"r each integer passed

&AR&T/RP/NTA(' s%n"n%m !"r &ARP/NTA('

&+N&TP=S(' Returns c"ncatenate ith separat"r 

&+N&T(' Returns c"ncatenated string

&+N.(' &"n$erts numers eteen di!!erent numer ases

/T(' Returns string at inde9 numer 

/E)+RTPS/T(' Returns a string such that !"r e$er% it set in the $alue its, %"u get an "n string and !"r e$er% unset it, %"u get an "!! stringG/D(' Returns the inde9 (p"siti"n' "! the !irst argument in the suse8uent arguments

GNDPNPS/T(' Returns the inde9 p"siti"n "! the !irst argument ithin the sec"nd argument

G+RMT(' Returns a numer !"rmatted t" speci!ied numer "! decimal places

A/E(' Returns a string representati"n "! a he9 $alue

NS/RT(' nserts a sustring at the speci!ied p"siti"n up t" the speci!ied numer "! characters

NSTR(' Returns the inde9 "! the !irst "ccurrence "! sustring

&S/(' S%n"n%m !"r +=/R('

/GT(' Returns the le!tm"st numer "! characters as speci!ied

/NTA(' Returns the length "! a string in %tes

+DPG/(' "ads the named !ile

+&T/(' Returns the p"siti"n "! the !irst "ccurrence "! sustring

+=/R(' Returns the argument in l"ercase

)D(' Returns the string argument, le!t-padded ith the speci!ied string

TRM(' Rem"$es leading spaces

MK/PS/T(' Returns a set "! c"mma-separated strings that ha$e the c"rresp"nding it in its set

MD(' Returns a sustring starting !r"m the speci!ied p"siti"n

+&T(' Returns a string representati"n "! the "ctal argument

+&T/TP/NTA(' s%n"n%m !"r /NTA('

+RD(' ! the le!tm"st character "! the argument is a multi-%te character, returns the c"de !"r that character 

)+ST+N(' s%n"n%m !"r +&T/('

7#+T/(' /scapes the argument !"r use in an S7 statement

R//E) )attern matching using regular e9pressi"ns

R/)/T(' Repeats a string the speci!ied numer "! times

R/)&/(' Replaces "ccurrences "! a speci!ied string

R/./RS/(' Re$erses the characters in a string

RAT(' Returns the speci!ied rightm"st numer "! characters

R)D(' ppends string the speci!ied numer "! timesRTRM(' Rem"$es trailing spaces

S+#ND/E(' Returns a s"unde9 string

S+#NDS K/ &"mpares s"unds

S)&/(' Returns a string "! the speci!ied numer "! spaces

STR&M)(' &"mpares t" strings

S#1STRNPND/E(' Returns a sustring !r"m a string e!"re the speci!ied numer "! "ccurrences "! the delimiter 

S#1STRN(', S#1STR(' Returns the sustring as speci!ied

TRM(' Rem"$es leading and trailing spaces

#&S/(' S%n"n%m !"r #))/R('

#NA/E(' &"n$erts each pair "! he9adecimal digits t" a character 

#))/R(' &"n$erts t" uppercase

S+, (#meric F#nction"

S7 numeric !uncti"ns are used primaril% !"r numeric manipulati"n and4"r mathematical calculati"ns The !"ll"ing

tale details the numeric !uncti"nsB

(ame )e"cri2tion

1S(' Returns the as"lute $alue "! numeric e9pressi"n

&+S(' Returns the arcc"sine "! numeric e9pressi"n Returns N# i! the $alue is n"t in the range - t"

SN(' Returns the arcsine "! numeric e9pressi"n Returns N# i! $alue is n"t in the range - t"

TN(' Returns the arctangent "! numeric e9pressi"n

TN2(' Returns the arctangent "! the t" $ariales passed t" it

1TPND(' Returns the itise ND all the its in e9pressi"n

;

Page 12: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 12/238

1TP&+#NT(' Returns the string representati"n "! the inar% $alue passed t" it

1TP+R(' Returns the itise +R "! all the its in the passed e9pressi"n

&/(' Returns the smallest integer $alue that is n"t less than passed numeric e9pressi"n

&/N(' Returns the smallest integer $alue that is n"t less than passed numeric e9pressi"n

&+N.(' &"n$ert numeric e9pressi"n !r"m "ne ase t" an"ther

&+S(' Returns the c"sine "! passed numeric e9pressi"n The numeric e9pressi"n sh"uld e e9pressed in radians

&+T(' Returns the c"tangent "! passed numeric e9pressi"n

D/R//S(' Returns numeric e9pressi"n c"n$erted !r"m radians t" degrees

/E)(' Returns the ase "! the natural l"garithm (e' raised t" the p"er "! passed numeric e9pressi"nG++R(' Returns the largest integer $alue that is n"t greater than passed numeric e9pressi"n

G+RMT(' Returns a numeric e9pressi"n r"unded t" a numer "! decimal places

R/T/ST(' Returns the largest $alue "! the input e9pressi"ns

NT/R.('Takes multiple e9pressi"ns e9p, e9p2 and e9p3 s" "n and returns 0 i! e9p is less than e9p2, returns i!

e9p is less than e9p3 and s" "n

/ST(' Returns the minimum-$alued input hen gi$en t" "r m"re

+(' Returns the natural l"garithm "! the passed numeric e9pressi"n

+0(' Returns the ase-0 l"garithm "! the passed numeric e9pressi"n

M+D(' Returns the remainder "! "ne e9pressi"n % di$ing % an"ther e9pressi"n

+&T('Returns the string representati"n "! the "ctal $alue "! the passed numeric e9pressi"n Returns N# i! passe

$alue is N#

)(' Returns the $alue "! pi

)+=(' Returns the $alue "! "ne e9pressi"n raised t" the p"er "! an"ther e9pressi"n

)+=/R(' Returns the $alue "! "ne e9pressi"n raised t" the p"er "! an"ther e9pressi"n

RDNS(' Returns the $alue "! passed e9pressi"n c"n$erted !r"m degrees t" radians

R+#ND('Returns numeric e9pressi"n r"unded t" an integer &an e used t" r"und an e9pressi"n t" a numer "! decim

 p"ints

SN(' Returns the sine "! numeric e9pressi"n gi$en in radians

S7RT(' Returns the n"n-negati$e s8uare r""t "! numeric e9pressi"n

STD(' Returns the standard de$iati"n "! the numeric e9pressi"n

STDD/.(' Returns the standard de$iati"n "! the numeric e9pressi"n

TN(' Returns the tangent "! numeric e9pressi"n e9pressed in radians

TR#N&T/(' Returns numeric e9p truncated t" e9p2 decimal places ! e9p2 is 0, then the result ill ha$e n" decimal p"int

LIST OF EPERIMENTS

. Creation of a data$a"e and writin- S+, ;#erie" to retrie5e information from the data$a"e.

;.;)ata )efinition ,an-#a-e /)),0.

a &R/T/

  T/R 

c DR+)

d TR#N&T/

e R/NM/

! &+MM/NT

;.2)ata Mani2#lation ,an-#a-e /)M,0

a NS/RT

  #)DT/

c D//T/

;

Page 13: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 13/238

d S//&T

<. Performin- n"ertion' )eletion' Modifin-' &lterin-' %2datin- and !iewin- record" $a"ed on

condition".

=. Creation of !iew"' Snonm"' Se;#ence' nde1e"' Sa5e 2oint.

=.. m2lementation of !iew".

32 m2lementation of Snonm"

33 m2lementation of Se;#ence

3: m2lementation of nde1e"

3; m2lementation of Sa5e 2oint.

>. Creatin- an Em2loee data$a"e to "et 5ario#" con"traint".

(a' )rimar% ke%, (e'Null, (i' Disale &"nstraints

('G"reign Ke%, W (!' N"t null, (@' Dr"p &"nstraints

(c' &heck, (g' De!ault,

(d' #ni8ue, (h' /nale &"nstraints,

?. Creatin- relation"hi2 $etween the data$a"e".

?. m2lementation of "et o2eration"

?.<. m2lementation of (e"ted +#erie" 4 S#$;#erie"

?.<. m2lementation the Join O2eration"

@. St#d of P,4S+, $lock.

A. 9rite a P,4S+, $lock to "ati"f "ome condition" $ acce2tin- in2#t from the #"er.

. 9rite a P,4S+, $lock that handle" all t2e" of e1ce2tion".

. Creation of Proced#re".

D. Creation of data$a"e tri--er" and f#nction"

D. m2lementation of Tri--er" and it" a22lication

;

Page 14: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 14/238

D.< m2lementation of F#nction".

. Mini 2roect /&22lication )e5elo2ment #"in- Oracle4 M";l 0

a' n$ent"r% &"ntr"l S%stem

 ' Material Re8uirement )r"cessing

c' A"spital Management S%stem

d' Raila% Reser$ati"n S%stem

e' )ers"nal n!"rmati"n S%stem

!' =e 1ased #ser denti!icati"n S%stem

g' Timetale Management S%stem

h' A"tel Management S%stem 

Creation of a data$a"e and writin- S+, ;#erie" to retrie5e information from the data$a"e.

E1: (o: D/.0 )&T& )EF(TO( ,&(6%&6E/)),0

  : :  

&M:

T" e9ecute the $ari"us Data De!initi"n anguage c"mmands in RD1MS

OBJECT!E:

!ter c"mpleting the e9ercise the students can ale t" #nderstand h" t" create a tale ith list "!ields, M"di!% a r" using here clause, Dr"p a tale, Delete the unanted r"s in a tale

)&T& )EF(TO( ,&(6%&6E

t is used t" c"mmunicate ith dataase DD is used t"B

;

Page 15: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 15/238

&reate an "@ect

lter the structure "! an "@ect

T" dr"p the "@ect created

&,6ORTHM:

Step B Start the pr"gram

Step 2B " t" S7

Step 3B /nter the user name and pass"rd

Step :B &"nnect t" the dataase

Step ;B T%pe the c"mmands !"r creating tales and per!"rm $ari"us "perati"ns "n the tales

Step 6B The "utput is displa%ed

Step <B St"p the pr"gram

)), COMM&():

• &R/T/

• T/R 

• DR+)

• TR#N&T/

• &+MM/NT

• R/NM/

CRE&TE T&B,E

&"nstraints are c"nditi"n !"r the data item t" e st"red int" a dataase There are t" t%pes "!

&"nstraints $iF, &"lumn &"nstraints and Tale &"nstraintsT!"#$s

n relati"nal dataase s%stems (D1S' data are represented using tales (relati"ns' 8uer% issued

against the D1S als" results in a tale tale has the !"ll"ing structureB

Tuple "r rec"rd

Tuple "r rec"rd 2

Tuple "r rec"rd n

tale is uni8uel% identi!ied % its name and c"nsists "! r"s that c"ntain the st"red

in!"rmati"n, each r" c"ntaining e9actl% "ne tuple ("r rec"rd' tale can ha$e "ne "r m"re c"lumns

c"lumn is made up "! a c"lumn name and a data t%pe, and it descries an attriute "! the tuples The

structure "! a tale, als" called relati"n schema, thus is de!ined % its attriutes The t%pe "!

;

Col#mn Col#mn < Col#mn n

Page 16: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 16/238

in!"rmati"n t" e st"red in a tale is de!ined % the data t%pes "! the attriutes at tale creati"n time

+racle "!!ers the !"ll"ing asic data t%pes:

Sl.(o )ata T2e )e"cri2tion

Char/n0 &haracter String n is the siFe "! $ariale Ma9imum siFe is 2;; characters The de!ault siFe is

< V!%c&!%'(n)

-harac!er s!rin% . n is !he si=e $# !he ,ariabe

= (#m$er enes 0umeric da!a !ype 1i!h space #$r 4< di%i! and space #$r si%n and decima p$in!> (#m$er /n0 0umeric ,ariabe.n is !he si=e $# !he ,ariabe

? (#m$er/n'd0  Numeric $arialen is the siFe "! $ariale and d is the siFe i! the decimal p"int

@ Raw/"iGe0 +a1 Binary da!a $# en%!h si=e by!es .a9imum si=e is 32767 by!es.A nte-er I! is same as number da!a !ype bu! ,aues 1i be 1h$e numbers. -$umns dened 1i!h !his

#$rma! n$! accep! decima ,aues. nte-er/n0 Species an in!e%er da!a !ype $# en%!h n. ,on- De!ines a character data t%pe upt" 32<60%tes +ne "ne l"ng c"lumn ma% e e!ined !"r tale This t%pe "! c"lumn

ma% n"t e used in su 8ueries, =here clauses "r inde9es

D ,on- Raw Same as +N e9cept it c"ntains inar% data "r %te strings and n"t interpreted % )4S7

,OB T2e LB ,ariabes can used in!erchan%eaby 1i!h L0( and L0( +&: ,ariabes. I! c$nsis!s $#BIL>BLB>-LB and 0LB

< BF,E I! is used !$ s!$re ar%e binary $b?ec!s in $pera!in% sys!em es $u!side !he da!abase= B,OB The 1+1 datat %pe t" st"re large inar% "@ects in the dataase, in-line "r "ut-"!-line /$er% 1+1 $ariale st"re

a l"cat"r, hich p"ints t" a large inar% "@ect The siFe "! a 1+1 cann"t e9ceed !"ur giga%tes

> C,OB The &+1 datat%pe t" st"re large l"cks "! character data in the dataase, in-line "r "ut-"!-line 1"th !i9ed-idthand $ariale-idth character sets are supp"rted /$er% &+1 $ariale st"res a l"cat"r, hich p"ints t" a large l"c

"! character data The siFe "! a &+1 cann"t e9ceed !"ur giga%tes

? (C,OB The N&+1 datat%pe t" st"re large l"cks "! N&AR data in the dataase, in-line "r "ut-"!-line 1"th !i9ed-idth

and $ariale-idth character sets are supp"rted /$er% N&+1 $ariale st"res a l"cat"r, hich p"ints t" a large

 l"ck "! N&AR data The siFe "! an N&+1 cann"t e9ceed !"ur giga%tes

@

)&TE

The DT/ datat%pe t" st"re !i9ed-length datetimes, hich include the time "! da% in sec"nds since midnight The

date p"rti"n de!aults t" the !irst da% "! the current m"nth the time p"rti"n de!aults t" midnight The date !uncti"nSHSDT/ returns the current date and time

S7 uses the terms tale, r", and c"lumn !"r relati"n, tuple, and attriute, respecti$el% tale can ha$

up t" 2;: c"lumns hich ma% ha$e di!!erent "r same data t%pes and sets "! $alues (d"mains', respecti$el

)"ssile d"mains are alphanumeric data (strings', numers and date !"rmats

Sample Dataases used !"r illustrati"n "! S7 &"mmands is gi$en el" ith /R Diagram and c"rresp"nding Relati"nal

M"del ith suitale data entered in the tales

• Relati"n eteen /mpl"%ee and Department is ="rks is man% *t"-"ne

DT1S/ !"r /M)+H// and D/)RTM/NT /ntities

EMP  Tale gi$en ith sample Data

EMP(O E(&ME JOB M6R HRE)&TE S&, COMM )EPT(O

;

Page 17: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 17/238

<36? SMTA &/RK <?02 <-D/&->0 >00 20

<:?? /N S/SMN <6?> 20-G/1-> 600 300 30

<;2 =RD S/SMN <6?> 22-G/1-> 2;0 ;00 30

<;66 +N/S MN/R <>3? 02-)R-> 2?<; 20

<6;: MRTN S/SMN <6?> 2>-S/)-> 2;0 :00 30

)EPT Tale gi$en ith Sample Data

)EPT(O )(&ME ,OC

0 &&+#NTN N/= H+RK  

20 R/S/R&A DS

30 S/S &A&+

:0 +)/RT+NS 1+ST+N

+%ER: D

+: =rite a 8uer% t" create a tale empl"%ee ith empn", ename, designati"n, and salar%

Snta1: t is used t" create a tale

S7B &R/T/ U+1TH)/VU+1NM/V (&+#MN NM/ UDTTH)/V (SO/',

&+#MN NM/2 UDTTH)/V (SO/' XXX'

Command:

S7VCRE&TE T&B,E /M) (/M)N+ (%MBER />0'/NM/ !&RCH&R< /D0' D/SNTN !&RCH&R<

/D0'SRH (%MBER /' <00I

Tale created

Con"traint" with Ta$le Creation:

&"nstraints are c"nditi"n !"r the data item t" e st"red int" a dataase There are t" t%pes "!

&"nstraints $iF, &"lumn &"nstraints and Tale &"nstraints

Snta1:

Y&+NSTRNT c"nstraint nameZ

[YN+TZ N# 4 #N7#/ 4 )RMRH K/H\(&"lumnY,c"lumnZ'

G+R/N K/H (c"lumn Y, c"lumZX'

;

Page 18: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 18/238

Page 19: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 19/238

+%ER: D>

+>: =rite a 8uer% !"r create a !r"m an e9isting tale ith selected !ields

Snta1: S%nta9 !"r create a !r"m an e9isting tale ith selected !ields

S7V &R/T/ T1/ UTR/T T1/ NM/V S S//&T /M)N+, /NM/GR+M US+#R&/

T1/ NM/V

Command:

S7V &R/T/ T1/ EMP< S S//&T EMP(O, E(&ME GR+M EMP

Tale created

Command:

S7V D/S& /M)2

 Name Null] T%pe

----------------- --------------------- ----/M)N+ N#M1/R (:'

/NM/ .R&AR2 (0'

+%ER: D?

+?: =rite a 8uer% !"r create a ne tale !r"m an e9isting tale ith"ut an% rec"rdB

Snta1: The s%nta9 !"r create a ne tale !r"m an e9isting tale ith"ut an% rec"rd

S7V &R/T/ T1/ UTR/T T1/ NM/V S S//&T Q GR+MUS+#R&/ T1/ NM/V

=A/R/ UGS/ &+NDT+NV

Command:

S7V &R/T/ T1/ /M)3 S S//&T Q GR+M /M) =A/R/V2

Tale created

Command:

S7V D/S& /M)3

 Name Null] T%pe

------------------ -----------------------

/M)N+ N#M1/R(:'

/NM/ .R&AR2(0'

D/SNTN.R&AR2(0'

SRH N#M1/R(>,2'

;

Page 20: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 20/238

&,TER K MO)FC&TO( O( T&B,E

T" m"di!% structure "! an alread% e9isting tale t" add "ne m"re c"lumns and als" m"di!% the

e9isting c"lumns

lter c"mmand is used t"B

dd a ne c"lumn

2 M"di!% the e9isting c"lumn de!initi"n

3 T" include "r dr"p integrit% c"nstraint

+%ER: D@

+@: =rite a 7uer% t" lter the c"lumn /M)N+ N#M1/R (:' T+ /M)N+ N#M1/R (6'

Snta1: The s%nta9 !"r alter 5 m"di!% "n a single c"lumn

S7 V T/R UT1/ NM/V M+DGH U&+#MN NM/VUDTTH)/V(SO/'

Command:

S7VT/R T1/ EMP M+DGH EMP(O N#M1/R (6'

Tale altered

2

Page 21: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 21/238

Command:

S7V D/S& /M)

 Name Null] T%pe

----------------- ----------------------------------

/M)N+ N#M1/R(6'

/NM/ .R&AR2(0'

D/SNTN .R&AR2(0'SRH N#M1/R(>,2'

+%ER: DA

7< =rite a 7uer% t" lter the tale empl"%ee ith multiple c"lumns (/M)N+,/NM/'

Snta1: T" alter tale ith multiple c"lumn

S7 V T/R UT1/ NM/V M+DGH U&+#MN NM/VUDTTH)/V(SO/',

M+DGH U&+#MN NM/2VUDTTH)/V(SO/'XXXX

Command:

S7VT/R T1/ /M) M+DGH (/M)N+ N#M1/R (<', /NM/.R&AR2(2''

Tale altered

Command:

S7V D/S& /M)

 Name Null] T%pe

----------------- -------------------------------

/M)N+ N#M1/R(<'

/NM/ .R&AR2(2'

D/SNTN .R&AR2(0'SRH N#M1/R(>,2'

+%ER: D

7> =rite a 8uer% t" add a ne c"lumn in t" empl"%ee

Snta1: T" add a ne c"lumn

S7V T/R T1/ UT1/ NM/V DD (U&+#MN NM/VUDTTH)/VUSO/V'

Command:

S7V T/R T1/ /M) DD 7#G&T+N .R&AR2(6'

Tale altered

S7V D/S& /M)

 Name Null] T%pe

---------------- ------------------------

/M)N+ N#M1/R(<'

/NM/ .R&AR2(2'

D/SNTN .R&AR2(0'

SRH N#M1/R(>,2'

7#G&T+N .R&AR2(6'

2

Page 22: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 22/238

+%ER: D

+: =rite a 8uer% t" add multiple c"lumns in t" empl"%ee

Snta1: S%nta9 !"r add a ne c"lumn

S7V T/R T1/ UT1/ NM/V DD (U&+#MN NM/VUDTTH)/VUSO/V,

  (U&+#MN NM/2VUDT TH)/VUSO/VX'

Command:

S7VT/R T1/ /M) DD (D+1 DT/, D+ DT/'Tale altered

S7V D/S& /M)

 Name Null] T%pe

----------------- --------------------------------

/M)N+ N#M1/R(<'

/NM/ .R&AR2(2'

D/SNTN .R&AR2(0'

SRH N#M1/R(>,2'

7#G&T+N .R&AR2(6'

D+1 DT/

D+ DT/

REMO!E 4 )ROP

t ill delete the tale structure pr"$ided the tale sh"uld e empt%

+%ER: D

70 =rite a 8uer% t" dr"p a c"lumn !r"m an e9isting tale empl"%ee

Snta1: s%nta9 !"r add a ne c"lumn

S7V T/R T1/ UT1/ NM/V DR+) &+#MN U&+#MN NM/V

Command:

S7V T/R T1/ /M) DR+) &+#MN D+

Tale altered

S7V D/S& /M)

 Name Null] T%pe

----------------- ------------------------------

/M)N+ N#M1/R(<'

/NM/ .R&AR2(2'

D/SNTN .R&AR2(0'

SRH N#M1/R(>,2'

7#G&T+N .R&AR2(6'

D+1 DT/

+%ER:

70 =rite a 8uer% t" dr"p multiple c"lumns !r"m empl"%ee

Snta1:The S%nta9 !"r add a ne c"lumn

S7V T/R T1/ UT1/ NM/V DR+) U&+#MNNM/V,U&+#MN NM/2V,XXX

2

Page 23: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 23/238

Command:

S7V T/R T1/ /M) DR+) (D+1, 7#G&T+N'

Tale altered

S7V D/S& /M)

 Name Null] T%pe

------------------ ---------------------------

/M)N+ N#M1/R(<'

/NM/ .R&AR2(2'

D/SNTN .R&AR2(0'

SRH N#M1/R(>,2'

RE(&ME

+%ER: <

70 =rite a 8uer% t" rename tale emp t" empl"%ee

Snta1:The S%nta9 !"r add a ne c"lumn

S7V T/R T1/ R/NM/ U+D NM/V T+ UN/= NM/V

Command:

S7V T/R T1/ R/NM/ /M) T+ /M)+H//

S7V D/S& /M)+H//

 Name Null] T%pe

------------------- --------------------------

/M)N+ N#M1/R(<'

/NM/ .R&AR2(2'

D/SNTN .R&AR2(0'

SRH N#M1/R(>,2'

TR%(C&TE T&B,E

! there is n" !urther use "! rec"rds st"red in a tale and the structure has t" e retained then the rec"rds al"ne

can e deleted

Snta1:

TR#N&T/ T1/ UT1/ NM/V

E1am2le:

Truncate tale /M)

2

Page 24: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 24/238

)ROP:

T" rem"$e a tale al"ng ith its structure and data

Snta1:The S%nta9 !"r add a ne c"lumn

S7V Dr"p taleUtale nameV

Command:

S7V dr"p tale empl"%ee

RES%,T:

Thus the S7 c"mmands !"r DD c"mmands in RD1MS has een $eri!ied and e9ecuted success!ull%

)&T& M&(P%,&TO( ,&(6%&6E /)M,0 COMM&()S ( R)BMS

E1: (o: .<

  : :  

&M:

T" e9ecute and $eri!% the DM c"mmands are the m"st !re8uentl% used S7 c"mmands and is used

t" 8uer% and manipulate the e9isting dataase "@ects

)M, /)&T& M&(P%,&TO( ,&(6%&6E0

• S//&T

• NS/RT

• D//T/

• #)DT/

&,6ORTHM:

STEP : Start the D1MS

STEP <: &reate the tale ith its essential attriutes

STEP =: nsert the rec"rd int" tale

STEP >: #pdate the e9isting rec"rds int" the tale

STEP ?: Delete the rec"rds in t" the tale

STEP @:  use sa$e p"int i! an% changes "ccur in an% p"rti"n "! the rec"rd t" und" its "riginal

state

2

Page 25: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 25/238

STEP A: use r"llack !"r c"mpletel% und" the rec"rds

STEP : use c"mmit !"r permanentl% sa$e the rec"rds

(SERT

The S7 NS/RT NT+ Statement is used t" add ne r"s "! data t" a tale in the dataase

n"ert a record from an e1i"tin- ta$le:

+%ER: D

7 =rite a 8uer% t" insert the rec"rds in t" empl"%ee

Snta1: s%nta9 !"r insert rec"rds in t" a tale

S+, :L (SERT (TO T&B,E (&MEL !&,%ES !&,' N!&,<*'..0I

Command:

S7VNS/RT NT+ /M) .#/S (0,INRNI,I/&T#R/RI,;000'

r" created

n"ert & Record %"in- S#$"tit#tion Method:

+%ER: D=

73 =rite a 8uer% t" insert the rec"rds in t" empl"%ee using sustituti"n meth"d

Snta1: s%nta9 !"r insert rec"rds int" the tale

S7 BV NS/RT NT+ UT1/ NM/V .#/SU L5c"lumn name, L5c"lumn name 2, X'

Command:

S7V NS/RT NT+ /M) .#/S(5/M)N+,I5/NM/I,I5D/SNTNI,I5SRHI'

/nter $alue !"r empn"B 02

/nter $alue !"r enameB SR.NN

/nter $alue !"r designatinB /&T#R/R 

2

Page 26: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 26/238

/nter $alue !"r salar%B ;000

r" created

old : NS/RT NT+ /M) .#/S(5/M)N+,I5/NM/I,I5D/SNTNI,I5SRHI'

new : NS/RT NT+ /M) .#/S(02,ISR.NNI,I/&T#R/RI,I;000I'

S7V 4

/nter $alue !"r empn"B 03

/nter $alue !"r enameB )NN/RS/.M/nter $alue !"r designatinB SST )R+G

/nter $alue !"r salar%B 20000

r" created

old : NS/RT NT+ /M) .#/S(5/M)N+,I5/NM/I,I5D/SNTNI,I5SRHI'

new : NS/RT NT+ /M) .#/S(03,I)NN/RS/.MI,ISST)R+GI,I20000I'

S7V 4

/nter $alue !"r empn"B 0:

/nter $alue !"r enameB &ANN

/nter $alue !"r designatinB A+D, )R+G

/nter $alue !"r salar%B :;000

r" created

old : NS/RT NT+ /M) .#/S(5/M)N+,I5/NM/I,I5D/SNTNI,I5SRHI'

new : NS/RT NT+ /M) .#/S(0:,I&ANNI,IA+D, )R+GI,I:;000I'

S7V S//&T Q GR+M /M)

/M)N+ /NM/ D/SNTN SRH----------- ------------ ------------------- --------------

0 NRN /&T#R/R ;000

02 SR.NN /&T#R/R ;000

03 )NN/RS/.M SST )R+G 20000

0: &ANN A+D, )R+G :;000

SE,ECT

SE,ECT Statement is used t" !etch the data !r"m a dataase tale hich returns data in the !"rm "!

result tale These result tales are called result-sets

)i"2la the EMP ta$le:

+%ER: D<

2

Page 27: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 27/238

Page 28: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 28/238

Command:

S7V#)DT/ /M) S/T SRH 6000, D/SNTNISST )R+GI =A/R/ /M)N+02

r" updated

S7V S//&T Q GR+M /M)

/M)N+ /NM/ D/SNTN SRH

---------- ------------ -------------------- --------------

0 NRN /&T#R/R 6000

02 SR.NN SST )R+G 6000

03 )NN/RS/.M SST )R+G 20000

0: &ANN A+D, )R+G :;000

)E,ETE

The S+, )E,ETE 7uer% is used t" delete the e9isting rec"rds !r"m a tale H"u can use 9HERE

clause ith )E,ETE 8uer% t" delete selected r"s, "therise all the rec"rds "uld e deleted

+%ER: D@

7; =rite a 8uer% t" delete rec"rds !r"m empl"%ee

Snta1: Snta1 for delete Record" from the ta$le:

S7V D//T/ UT1/ NM/V =A/R/ U&+#MN NM/VU.#/V

Command:

S7V D//T/ /M) =A/R/ /M)N+03

r" deleted

S7V S//&T Q GR+M /M)

/M)N+ /NM/ D/SNTN SRH

---------- ------------ --------------------- --------------

0 NRN /&T#R/R 6000

02 SR.NN SST )R+G 6000

0: &ANN A+D, )R+G :;000

2

Page 29: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 29/238

RES%,T:

Thus the S7 c"mmands !"r DM has een $eri!ied and e9ecuted success!ull%

Performin- n"ertion' )eletion' Modifin-' &lterin-' %2datin- and !iewin- record" $a"ed on

condition".

E1: (o: D<

  : :  

&M:

T" per!"rming inserti"n, deleti"n, m"di!%ing, altering, updating and $ieing rec"rds ased "n

c"nditi"ns

&,6ORTHM:

STEP : Start the D1MS

STEP <: &"nnect t" the dataase (D1'

STEP =: &reate the tale ith its essential attriutes

STEP >: nsert the rec"rd int" tale ased "n s"me c"nditi"n using =A/R/ &#S/

STEP ?: #pdate the e9isting rec"rds int" the tale ased "n s"me c"nditi"n

STEP @: Delete the rec"rds in t" the tale ased "n s"me c"nditi"n

STEP A: #se c"mmit !"r permanentl% sa$e the rec"rds

STEP : St"p the pr"gram

2

Page 30: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 30/238

)R,3)&T& RETRE!&, MP,EME(T(6 O( SE,ECT COMM&()S

Command:

S7V &R/T/ T1/ /M)(

/M)N+ N#M1/R (:',

/NM/ .R&AR2 (0',

+1 .R&AR2(20',

MR N#M1/R(:',

AR/DT/ DT/,

S N#M1/R(>,2',

D/)TN+ N#M1/R(3'

 '

Tale created

S7V NS/RT NT+ /M) .#/S(<36?,ISMTAI,I&/RKI,;00,I<-D/&->0I,I>000I,200' r" created

S7V NS/RT NT+ /M) .#/S(<:??,I/NI,IS/SMNI,;002,I20-G/1->0I,I3000I,300'

r" created

S7V NS/RT NT+ /M) .#/S(<;2,I=RDI,IS/SMNI,;003,I22-G/1->0I,I;000I,;00'

r" created

S7V NS/RT NT+ /M) .#/S(<;66,I+N/SI,IMN/RI,;002,I02-)R->;I,I<;000I,200'

r" created

S7V NS/RT NT+ /M) .#/S(<;66,IRI,I+=N/RI,;000,I30-)R-<;I,N#,00'

r" created

S7V NS/RT NT+ /M) .#/S(<;66,IK#MRI,I&+/I,;002,I2-N-><I,I;;000I,300'

r" created

S7V NS/RT NT+ /M) .#/S(<:??,IRM K#MRI,ISRS/SMNI,;003,I22-N-><I,I2000;;I,200'

r" created

3

Page 31: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 31/238

S7V NS/RT NT+ /M) .#/S(<;2,ISM K#MRI,ISRS/SMNI,;003,I22-N-<;I,I22000I,300'

r" created

THE SE,ECT ST&TEME(T S(T&7 9TH &))TO(&, C,&%SES:

Select Y Distinct 4 #ni8ue Z ( Qc"lumnname Y s alias\, XZ

Gr"m talename

Y here c"nditi"n ZY r"up 1H gr"up P%Pe9pressi"n Z

YAa$ing gr"upPc"nditi"n Z

Y+RD/R 1H [col(s)|expr|numeric_pos\ YS&^D/S&Z YN#S GRST^STZZ

S7V S//&T Q GR+M /M)

/M)N+ /NM/ +1 MR AR/DT/ S D/)TN+

------------ ---------------- --------------- ----------- ----------------- -------------- --------------------

<36? SMTA &/RK ;00 <-D/&->0 >000 200<:?? /N S/SMN ;002 20-G/1->0 3000 300

<;2 =RD S/SMN ;003 22-G/1->0 ;000 ;00

<;66 +N/S MN/R ;002 02-)R->; <;000 200

<;66 R +=N/R ;000 30-)R-<; 00

<;66 K#MR &+/ ;002 2-N->< ;;000 300

<:?? RM K#MR SRS/SMN ;003 22-N->< 2000;; 200

<;2 SM K#MR SRS/SMN ;003 22-N-<; 22000 300

> r"s selected

B %S(6 SE,ECTE) CO,%(MS

S7V S//&T /M)N+,/NM/,+1,S GR+M /M)

/M)N+ /NM/ +1 S

----------- ----------- ----------- --------------

<36? SMTA &/RK >000

<:?? /N S/SMN 3000

<;2 =RD S/SMN ;000

<;66 +N/S MN/R <;000

<;66 R +=N/R 

<;66 K#MR &+/ ;;000

<:?? RM K#MR SRS/SMN 2000;;

<;2 SM K#MR SRS/SMN 22000

> r"s selected

S7V S//&T /M)N+,/NM/,+1,S GR+M /M) =A/R/ S;000

/M)N+ /NM/ +1 S

--------- ---------- -------------------- ----------

<;2 =RD S/SMN ;000

3

Page 32: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 32/238

B %S(6 BET9EE( 4 (OT 4 ( 4 (%,, 4 ,8E

BETWEEN S*nt!+:S//&T column_name(s)

GR+M table_name

=A/R/ column_name 1/T=//N value1 ND value2;

S7V S//&T /M)N+,/NM/,+1,S GR+M /M) =A/R/ S BET9EE( 0000 ND 30000

/M)N+ /NM/ +1 S

---------- ------------------- ------------- -------------

<:?? RM K#MR SRS/SMN 2000;;

<;2 SM K#MR SRS/SMN 22000

S7V S//&T /M)N+,/NM/,+1,S GR+M /M) =A/R/ S (OT BET9EE( 0000 &() 30000

/M)N+ /NM/ +1 S

----------- ---------------- ------------ ------------

<36? SMTA &/RK >000

<:?? /N S/SMN 3000<;2 =RD S/SMN ;000

<;66 +N/S MN/R <;000<;66 K#MR &+/ ;;000

IN S*nt!+

SL-T column_name(s)

+ table_name

:@+ column_name I0 )value1>value2>...*A

S7V S//&T /M)N+,/NM/,+1,S GR+M /M) =A/R/ S ( (000;,<;000'

/M)N+ /NM/ +1 S

---------- ---------- ----------- -------

<;66 +N/S MN/R <;000

S7V S//&T /M)N+,/NM/,+1,S GR+M /M) =A/R/ S (OT ( (000;,<;000'

/M)N+ /NM/ +1 S

---------- ---------- -------------------- ----------

<36? SMTA &/RK >000

<:?? /N S/SMN 3000

<;2 =RD S/SMN ;000

<;66 K#MR &+/ ;;000

<:?? RM K#MR SRS/SMN 2000;;

<;2 SM K#MR SRS/SMN 22000

6 r"s selected

S7V S//&T /M)N+,/NM/,+1,S GR+M /M) =A/R/ S S (%,,

/M)N+ /NM/ +1 S

----------- ---------- ------------- ---------

<;66 R +=N/R 

S7V S//&T /M)N+,/NM/,+1,S GR+M /M) =A/R/ S S (OT (%,,

/M)N+ /NM/ +1 S

3

Page 33: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 33/238

---------- ---------- ------------ ---------

<36? SMTA &/RK >000<:?? /N S/SMN 3000

<;2 =RD S/SMN ;000

<;66 +N/S MN/R <;000

<;66 K#MR &+/ ;;000

<:?? RM K#MR SRS/SMN 2000;;

<;2 SM K#MR SRS/SMN 22000

< r"s selected

,8E Snta1:

S//&T column_name(s)

GR+M table_name

=A/R/ column_name K/ pattern

S7V S//&T /M)N+,/NM/,+1,S GR+M /M) =A/R/ S ,8E ;;000

/M)N+ /NM/ +1 S

---------- ---------- ---------------- ----------

<;66 K#MR &+/ ;;000

S7V S//&T /M)N+,/NM/,+1,S GR+M /M) =A/R/ /NM/ ,8E QSQI/M)N+ /NM/ +1 S

---------- ---------- -------------------- ----------

<36? SMTA &/RK >000

<;2 SM K#MR SRS/SMN 22000

S7V S//&T /M)N+,/NM/,+1,S GR+M /M) =A/R/ /NM/ ,8E QRQI

/M)N+ /NM/ +1 S

--------- ----------- ---------- --------------

<;66 K#MR &+/ ;;000<:?? RM K#MR SRS/SMN 2000;;

<;2 SM K#MR SRS/SMN 22000

S7V S//&T /M)N+,/NM/,+1,S GR+M /M) =A/R/ /NM/ ,8E Q%QI

/M)N+ /NM/ +1 S

---------- --------- - ---------------- ----------

<;66 K#MR &+/ ;;000

<:?? RM K#MR SRS/SMN 2000;;

<;2 SM K#MR SRS/SMN 22000

S7V S//&T /M)N+,/NM/,+1,S GR+M /M) =A/R/ /NM/ ,8E Q&QI

/M)N+ /NM/ +1 S

----------- ----------- ------------- ----------

<:?? /N S/SMN 3000

<;2 =RD S/SMN ;000<;66 R +=N/R 

<;66 K#MR &+/ ;;000

<:?? RM K#MR SRS/SMN 2000;;<;2 SM K#MR SRS/SMN 22000

6 r"s selected

S7V S//&T /M)N+,/NM/,+1,S GR+M /M) =A/R/ /NM/ ,8E Q,,QI

/M)N+ /NM/ +1 S

---------- ------------ --------------- ------------

<:?? /N S/SMN 3000

3

Page 34: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 34/238

S7V S//&T /M)N+,/NM/,+1,S GR+M /M) =A/R/ /NM/ ,8E QEQI

/M)N+ /NM/ +1 S---------- -- -------- ---- ------------- ----------

<:?? /N S/SMN 3000

<;66 +N/S MN/R <;000

S7V S//&T /M)N+,/NM/,+1,S GR+M /M) =A/R/ /NM/ ,8E Q%&QI

/M)N+ /NM/ +1 S

---------- ---------- - ------------------- ----------

<;66 K#MR &+/ ;;000

<:?? RM K#MR SRS/SMN 2000;;<;2 SM K#MR SRS/SMN 22000

S7V S//&T /M)N+,/NM/,+1,S GR+M /M) =A/R/ /NM/ ,8E QRQI  44= 

/M)N+ /NM/ +1 S

---------- ---------- ----------- ----------<;66 R +=N/R 

S7V S//&T /M)N+,/NM/,+1,S GR+M /M) =A/R/ /NM/ ,8E QRJQI

/M)N+ /NM/ +1 S

---------- ---------- ----------- --------

<;66 R +=N/R 

S7V S//&T /M)N+,/NM/,+1,S GR+M /M) =A/R/ /NM/ ,8E QMQI

/M)N+ /NM/ +1 S

------------ ------------ --------------- --------<36? SMTA &/RK >000

S7V S//&T /M)N+,/NM/,+1,S GR+M /M) =A/R/ /NM/ ,8E QMQI

n" r"s selected

S7V S//&T /M)N+,/NM/,+1,S GR+M /M) =A/R/ /NM/ ,8E QRQI  44 > 

/M)N+ /NM/ +1 S

---------- ---------- -------------- ----------

<;66 K#MR &+/ ;;000

S7V S//&T /M)N+,/NM/,+1,S GR+M /M) =A/R/ /NM/ ,8E Q8RQI  44 = 

/M)N+ /NM/ +1 S

---------- ---------- ----------- --------- ----------

<;66 K#MR &+/ ;;000

S7V S//&T /M)N+,/NM/,+1,S GR+M /M) =A/R/ /NM/ N+T ,8E QRJQI

/M)N+ /NM/ +1 S

----------- ----------- --------------- ----------

3

Page 35: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 35/238

<36? SMTA &/RK >000

<:?? /N S/SMN 3000<;2 =RD S/SMN ;000

<;66 +N/S MN/R <;000

<;66 K#MR &+/ ;;000

<:?? RM K#MR SRS/SMN 2000;;

<;2 SM K#MR SRS/SMN 22000

< r"s selected

RE,&TO(&, OPER&TOR 

S7V S//&T /M)N+,/NM/,+1,S GR+M /M) =A/R/ S;;000

/M)N+ /NM/ +1 S

---------- ---------- -------------------- ----------

<;66 K#MR &+/ ;;000

S7V S//&T /M)N+,/NM/,+1,S GR+M /M) =A/R/ S;;000

/M)N+ /NM/ +1 S

---------- ---------- -------------------- ----------

<36? SMTA &/RK >000

<:?? /N S/SMN 3000

<;2 =RD S/SMN ;000<;66 +N/S MN/R <;000

<:?? RM K#MR SRS/SMN 2000;;

<;2 SM K#MR SRS/SMN 22000

6 r"s selected

S7V S//&T /M)N+,/NM/,+1,S GR+M /M) =A/R/ SUV;;000

/M)N+ /NM/ +1 S

---------- ---------- -------------------- ----------

<36? SMTA &/RK >000

<:?? /N S/SMN 3000

<;2 =RD S/SMN ;000

<;66 +N/S MN/R <;000

<:?? RM K#MR SRS/SMN 2000;;

<;2 SM K#MR SRS/SMN 22000

6 r"s selected

S7V S//&T /M)N+,/NM/,+1,S GR+M /M) =A/R/ SV;;000

/M)N+ /NM/ +1 S

---------- ---------- ------------------- ----------

<;66 +N/S MN/R <;000

S7V S//&T /M)N+,/NM/,+1,S GR+M /M) =A/R/ SU;;000

/M)N+ /NM/ +1 S----------- ---------- -------------------- ----------

<36? SMTA &/RK >000<:?? /N S/SMN 3000

<;2 =RD S/SMN ;000<:?? RM K#MR SRS/SMN 2000;;

<;2 SM K#MR SRS/SMN 22000

S7V S//&T /M)N+,/NM/,+1,S GR+M /M) =A/R/ SU;;000

/M)N+ /NM/ +1 S

---------- ------------ -------------------- ----------

<36? SMTA &/RK >000<:?? /N S/SMN 3000

<;2 =RD S/SMN ;000

3

Page 36: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 36/238

<;66 K#MR &+/ ;;000

<:?? RM K#MR SRS/SMN 2000;;<;2 SM K#MR SRS/SMN 22000

6 r"s selected

S7V S//&T /M)N+,/NM/,+1,S GR+M /M) =A/R/ SV;;000

/M)N+ /NM/ +1 S

------------ ---------- ----------------- ---------

<;66 +N/S MN/R <;000

<;66 K#MR &+/ ;;000

&() 4 OR 

S7V S//&T /M)N+,/NM/,+1,S GR+M /M) =A/R/ +1ISRS/SMNI &() S22000

/M)N+ /NM/ +1 S

----------- ------------ ------------------ ----------

<;2 SM K#MR SRS/SMN 22000

S7V S//&T /M)N+,/NM/,+1,S GR+M /M) =A/R/ +1ISRS/SMNI OR  S22000

/M)N+ /NM/ +1 S

---------- ---------- -------------------- ----------

<:?? RM K#MR SRS/SMN 2000;;<;2 SM K#MR SRS/SMN 22000

S7V S//&T /M)N+,/NM/,+1,S GR+M /M)

=A/R/ S;000 &() (+1ISRS/SMNI OR  +1IS/SMNI'

/M)N+ /NM/ +1 S

---------- ---------- -------------------- ----------

<;2 =RD S/SMN ;000

OR)ER B

Snta1:S//&T column_name,column_name

GR+M table_name+RD/R 1H column_name,column_name S&^D/S&

S7V S//&T /M)N+,/NM/,+1,S GR+M /M) OR)ER B E(&ME

/M)N+ /NM/ +1 S

------------ ------------ -------------------- ----------<:?? /N S/SMN 3000

<;66 +N/S MN/R <;000

<;66 K#MR &+/ ;;000

<;66 R +=N/R 

<:?? RM K#MR SRS/SMN 2000;;<;2 SM K#MR SRS/SMN 22000

<36? SMTA &/RK >000

<;2 =RD S/SMN ;000

> r"s selected

S7V S//&T /M)N+,/NM/,+1,S GR+M /M) +RD/R 1H /NM/ )ESCI

/M)N+ /NM/ +1 S

----------- ------------ -------------------- ----------

<;2 =RD S/SMN ;000

<36? SMTA &/RK >000

3

Page 37: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 37/238

<;2 SM K#MR SRS/SMN 22000

<:?? RM K#MR SRS/SMN 2000;;<;66 R +=N/R 

<;66 K#MR &+/ ;;000

<;66 +N/S MN/R <;000

<:?? /N S/SMN 3000

> r"s selected

S7V S//&T /M)N+,/NM/,+1,S GR+M /M) +RD/R 1H /NM/ &SCI

/M)N+ /NM/ +1 S----------- ------------ -------------------- ----------

<:?? /N S/SMN 3000

<;66 +N/S MN/R <;000

<;66 K#MR &+/ ;;000

<;66 R +=N/R 

<:?? RM K#MR SRS/SMN 2000;;

<;2 SM K#MR SRS/SMN 22000

<36? SMTA &/RK >000

<;2 =RD S/SMN ;000

> r"s selected

TOP

44 TOP clause is n"t in "racle instead "! that RO9(%M

Snta1

S//&T column_name(s)

GR+M table_name

=A/R/ R+=N#M U number 

S7V S//&T /M)N+,/NM/,+1,S GR+M /M) =A/R/ RO9(%M >I

/M)N+ /NM/ +1 S------------ ---------- -------------------- ----------

<36? SMTA &/RK >000

<:?? /N S/SMN 3000

<;2 =RD S/SMN ;000

S7V S//&T /M)N+,/NM/,+1,S GR+M /M) =A/R/ RO9(%M > OR)ER B E(&MEI

/M)N+ /NM/ +1 S

----------- ---------- ------------------ ----------

<:?? /N S/SMN 3000

<36? SMTA &/RK >000

<;2 =RD S/SMN ;000

DISTINCT

S*nt!+:SELECT DISTINCT c$umnname,c$umnname

+ table_nameA

E1:

S7V S//&T )ST(CT +1 GR+M /M)

+1

3

Page 38: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 38/238

--------------------

&/RK S/SMN

SRS/SMN

MN/R 

&+/

+=N/R 

6 r"s selected

%S(6 &,TER 

This can e used t" add "r rem"$e c"lumns and t" m"di!% the precisi"n "! the datat%pe

a0 &))(6 CO,%M(

Snta1:

alter tale Utable_nameV add Ucol datatypeV

E1:

S7V D/S& /M)

 Name Null] T%pe ------------------------- ----------- ---------------------------

 /M)N+ N#M1/R(:' /NM/ .R&AR2(0'

 +1 .R&AR2(20'

 MR N#M1/R(:'

 AR/DT/ DT/

 S N#M1/R(>,2'

 D/)TN+ N#M1/R(3'

S7V alter tale /M) add TE numer

Tale altered

S7V D/S& /M)

 Name Null] T%pe

 ----------------------------------------- ------------------------ /M)N+ N#M1/R(:'

 /NM/ .R&AR2(0'

 +1 .R&AR2(20'

 MR N#M1/R(:' AR/DT/ DT/

 S N#M1/R(>,2'

 D/)TN+ N#M1/R(3'

 TE N#M1/R 

$0 REMO!(6 CO,%M(

Snta1:alter tale Utable_nameV dr"p Ucol datatypeV

E1:

S7V alter tale /M) dr"p c"lumn TE

Tale altered

S7V D/S& /M)

 Name Null] T%pe

 ------------------------ ----------------- ----------------------------

3

Page 39: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 39/238

Page 40: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 40/238

? r"s selected

/$en th"ugh the c"lumn is unused still it ill "ccup% mem"r%

d0 )ROPP(6 %(%SE) CO,%M(S

Snta1:

alter tale Utable_nameV dr"p unused c"lumns

E1:S7V alter tale /M) dr"p unused c"lumns

Tale altered

Q H"u can n"t dr"p indi$idual unused c"lumns "! a tale

e0 RE(&M(6 CO,%M(

Snta1:

alter tale Utable_nameV rename c"lumn Uold_col_nameV t" Unew_col_nameV

E1:

S7V alter tale /M) rename c"lumn S t" SRH

Tale altered

S7V D/S& /M)

 Name Null] T%pe

 --------------------- ------ ----------------------------

 /M)N+ N#M1/R(:'

 /NM/ .R&AR2(0'

 +1 .R&AR2(20'

 MR N#M1/R(:'

 AR/DT/ DT/

 SRH N#M1/R(>,2'

(SERT

Method

6E(ER&, (SERT COMM&():

S7V NS/RT NT+ /M)(/M)N+,/NM/,+1,MR,AR/DT/,SRH'

.#/S(,IRM#I,IS/SMNI,;063,I2-N-><I,I;6:3;;I'

r" created

Method <

9THO%T SPECF THE CO,%M(S )ET&,S

S7V NS/RT NT+ /mp .#/S(,IRM#I,IS/SMNI,;063,I2-N-><I,I;6:3;;I'

r" created

Method =

(SERT(6 )&T& (TO SPECFE) CO,%M(S

S7V NS/RT NT+ /M)(/M)N+,/NM/,+1' .#/S(,IRM#I,IS/SMNI'

r" created

Method >

B CH&(6E THE OR)ER OF CO,%M(S

4

Page 41: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 41/238

S7V NS/RT NT+ /M)(salar%,/M)N+,/NM/,+1' .#/S(3;000,,IRM#I,IS/SMNI'

r" created

S7V select Q !r"m emp

/M)N+ /NM/ +1 MR AR/DT/ SRH

---------- ---------- --------------- -------- -------------- ----------<36? SMTA &/RK ;00 <-D/&->0 >000

<:?? /N S/SMN ;002 20-G/1->0 3000

<;2 =RD S/SMN ;003 22-G/1->0 ;000

<;66 +N/S MN/R ;002 02-)R->; <;000<;66 R +=N/R ;000 30-)R-<;

<;66 K#MR &+/ ;002 2-N->< ;;000

<:?? RM K#MR SRS/SMN ;003 22-N->< 2000;;

<;2 SM K#MR SRS/SMN ;003 22-N-<; 22000<;2 SM K#MR SRS/SMN ;003 22-N-<; 22000

RM# S/SMN ;063 2-N->< ;6:3;;

RM# S/SMN ;063 2-N->< ;6:3;;

RM# S/SMN RM# S/SMN 3;000

3 r"s selected

Method ?

(SERT 9TH SE,ECT

#sing this e can insert e9isting tale data t" an"ther tale in a single trip 1ut the tale structure sh"uld e sameSnta1:

nsert int" Utable1V select Q !r"m Utable2V

E1:

S7V D/S& /M)

 Name Null] T%pe

------------------- ---------------------- ----------------------------/M)N+ N#M1/R(:'

/NM/ .R&AR2(0'

+1 .R&AR2(20'MR N#M1/R(:'

AR/DT/ DT/

SRH N#M1/R(>,2'

S7V create tale /M)+H//(/M)PN+,/M)PNM/,/M)P+1,AR,AR/DT/,SRH'

as select Q !r"m /M) here 2

Tale created

S7V D/S& /M)+H//

 Name Null] T%pe ----------------- ----------------- -------------------------

 /M)PN+ N#M1/R(:'

 /M)PNM/ .R&AR2(0'

 /M)P+1 .R&AR2(20'

 AR N#M1/R(:'

 AR/DT/ DT/

 SRH N#M1/R(>,2'

S7V S//&T Q GR+M /M)+H//

n" r"s selected

4

Page 42: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 42/238

S7V insert int" /M)+H// select Q !r"m /M)3 r"s created

S7V S//&T Q GR+M /M)+H//

/M)PN+ /M)PNM/ /M)P+1 AR AR/DT/ SRH

---------- ---------------- -------------------- -------- ---------------- ----------

<36? SMTA &/RK ;00 <-D/&->0 >000

<:?? /N S/SMN ;002 20-G/1->0 3000

<;2 =RD S/SMN ;003 22-G/1->0 ;000

<;66 +N/S MN/R ;002 02-)R->; <;000<;66 R +=N/R ;000 30-)R-<;

<;66 K#MR &+/ ;002 2-N->< ;;000

<:?? RM K#MR SRS/SMN ;003 22-N->< 2000;;

<;2 SM K#MR SRS/SMN ;003 22-N-<; 22000

<;2 SM K#MR SRS/SMN ;003 22-N-<; 22000

RM# S/SMN ;063 2-N->< ;6:3;; RM# S/SMN ;063 2-N->< ;6:3;;

RM# S/SMN

RM# S/SMN 3;000

3 r"s selected

Method @

M%,TB,E (SERTS

=e ha$e tale called D/)T ith the !"ll"ing c"lumns and data

S7V select Q !r"m D/)T

D/)TN+ DNM/ +&

----------- ---------- -------

0 acc"unting ne %"rk 

20 research dallas

30 sales &hicag"

:0 "perati"ns "st"n

CRE&TE ST%)E(T T&B,E

S7V &reate tale student(n" numer(2',name $archar(2',marks numer(3''

$0 M%,T (SERT 9TH &,, FE,)S

S7V nsert all

nt" student $alues(,a,00'

nt" student $alues(2,,200'

nt" student $alues(3,c,300'

Select Q!r"m dept here deptn"0

3 r"s created

S7V Select Q !r"m student

 N+ NM/ MRKS

------- -------- ----------

a 00

2 2003 c 300

4

Page 43: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 43/238

c0 M%,T (SERT 9TH SPECFE) FE,)S

S7V insert all

  nt" student (n",name' $alues(:,d'

  nt" student(name,marks' $alues(e,:00'

  nt" student $alues(3,c,300'

  Select Q!r"m dept here deptn"0

3 r"s created

S7V Select Q !r"m student

 N+ NM/ MRKS

------ -------- ---------

a 00

2 2003 c 300

: d

e :00

3 c 3006 r"s selected

d0 M%,T (SERT 9TH )%P,C&TE RO9S

S7V insert all

  nt" student $alues(,a,00'

  nt" student $alues(2,,200'

  nt" student $alues(3,c,300'

  Select Q!r"m dept here deptn" V 0

? r"s created

-- This inserts ? r"s ecause in the select statement retrie$es 3 rec"rds (3 inserts !"r each r" retrie$ed'

S7V Select Q !r"m student N+ NM/ MRKS

------ ---- -- ---------

a 00

2 2003 c 300

: d

  e :00

3 c 300

a 00

a 00

a 00

2 2002 200

2 200

3 c 300

3 c 300

3 c 300

; r"s selected

4

Page 44: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 44/238

e0 M%,T (SERT 9TH CO()TO(S B&SE)

S7V create tale m%tl(name $archar2(20',n" numer(0''

Ta$le created.

S7V insert int" m%tl $alues(IramI,'

row created.

S7V insert int" m%tl $alues(IsamI,222' row created.

S7V insert int" m%tl $alues(ItamI,333'

row created.

S7V select Q !r"m m%tl

(&ME (O

33333333333333333333 3333333333

ram

"am <<<

tam ===

S7V create tale %"urtl(name $archar2(20',n" numer(0''

Ta$le created.

S7V create tale %"urtl2(name $archar2(20',n" numer(0''

Ta$le created.

S7V create tale %"urtl3(name $archar2(20',n" numer(0''

Ta$le created

S7V select Q !r"m %"urtl

no row" "elected

S7V select Q !r"m %"urtl2

no row" "elected

S7V select Q !r"m %"urtl3

no row" "elected

S7V insert all

hen n" V then

int" %"urtl $alues(IramuI,'

hen name IsamI then

int" %"urtl2 $alues(IsamuI,2222'

hen name ItamI then

int" %"urtl3 $alues(ItamuI,3333'select Q !r"m m%tl here n" V

> row" created.

S7V select Q !r"m m%tl

(&ME (O

33333333333333333333 3333333333

ram

"am <<<

tam ===

4

Page 45: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 45/238

Page 46: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 46/238

S7V create tale m%tl(name $archar2(20',n" numer(0''Tale created

S7V insert int" m%tl $alues(IramI,'

r" created

S7V insert int" m%tl $alues(IsamI,222'

r" created

S7V insert int" m%tl $alues(ItamI,333' r" created

S7V select Q !r"m m%tl

 NM/ N+

-------------------- ----------

ram

sam 222

tam 333

S7V create tale %"urtl(name $archar2(20',n" numer(0''

Tale created

S7V create tale %"urtl2(name $archar2(20',n" numer(0''

Tale created

S7V create tale %"urtl3(name $archar2(20',n" numer(0''Tale created

S7V create tale %"urtl:(name $archar2(20',n" numer(0''

Tale created

S7V insert all

hen n" V then

int" %"urtl $alues(IramuI,'

hen name IsamI then

int" %"urtl2 $alues(IsamuI,2222'

hen name ItamI thenint" %"urtl3 $alues(ItamuI,3333'

else

int" %"urtl: $alues(Ich"ttaI,::::'

select Q !r"m m%tl here n" V

> row" created.

S7V select Q !r"m %"urtl

 NM/ N+

-------------------- ----------

ramu

ramu

S7V select Q !r"m %"urtl2

 NM/ N+

-------------------- ----------

samu 2222

S7V select Q !r"m %"urtl3

 NM/ N+

-------------------- ----------

tamu 3333

-0 M%,T (SERT 9TH CO()TO(S B&SE) &() FRST

4

Page 47: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 47/238

S7V create tale m%tl(name $archar2(20',n" numer(0''

Tale created

S7V insert int" m%tl $alues(IramI,'

r" created

S7V insert int" m%tl $alues(IsamI,222'

r" created

S7V insert int" m%tl $alues(ItamI,333'

r" created

S7V create tale %"urtl(name $archar2(20',n" numer(0''

Tale created

S7V create tale %"urtl2(name $archar2(20',n" numer(0''

Tale created

S7V create tale %"urtl3(name $archar2(20',n" numer(0''Tale created

S7V create tale %"urtl:(name $archar2(20',n" numer(0''

Tale created

S7V select Q !r"m m%tl

 NM/ N+

-------------------- ----------

ram

sam 222

tam 333

S7V insert !irst

hen n" then

int" %"urtl $alues(IramuI,'

hen name IsamI then

int" %"urtl2 $alues(IsamuI,2222'

hen name ItamI then

int" %"urtl3 $alues(ItamuI,3333'

select Q !r"m m%tl here nameIramI

r" created

S7V select Q !r"m %"urtl

 NM/ N+

-------------------- ----------

ramu

-- This inserts rec"rd ecause the !irst clause a$"id t" check the remaining c"nditi"ns "nce the c"nditi"n is satis!ied

h0 M%,T (SERT 9TH CO()TO(S B&SE)' FRST &() E,SE

S7V create tale m%tl(name $archar2(20',n" numer(0''

Tale created

4

Page 48: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 48/238

S7V insert int" m%tl $alues(IramI,'

r" created

S7V insert int" m%tl $alues(IsamI,222'

r" created

S7V insert int" m%tl $alues(ItamI,333'

r" created

S7V create tale %"urtl(name $archar2(20',n" numer(0''

Tale created

S7V create tale %"urtl2(name $archar2(20',n" numer(0''

Tale created

S7V create tale %"urtl3(name $archar2(20',n" numer(0''

Tale created

S7V create tale %"urtl:(name $archar2(20',n" numer(0''Tale created

S7V select Q !r"m m%tl NM/ N+

-------------------- ----------

ram

sam 222

tam 333

S7V insert !irst

hen n" then

int" %"urtl $alues(IramuI,'

hen name IamI then

int" %"urtl2 $alues(IsamuI,2222'

hen name ItamI thenint" %"urtl3 $alues(ItamuI,3333'

else

int" %"urtl: $alues(IkamuI,::::'

select Q !r"m m%tl here nameIramI

r" created

S7V select Q !r"m %"urtl

 NM/ N+

-------------------- ----------

ramu

S7V select Q !r"m %"urtl2

n" r"s selected

S7V select Q !r"m %"urtl3n" r"s selected

S7V select Q !r"m %"urtl:

n" r"s selected

i0 M%,T (SERT 9TH M%,TB,E T&B,ES

S7V create tale m%tl(name $archar2(20',n" numer(0''

Tale created

4

Page 49: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 49/238

S7V insert int" m%tl $alues(IramI,'

r" created

S7V insert int" m%tl $alues(IsamI,222'

r" created

S7V insert int" m%tl $alues(ItamI,333'

r" created

S7V select Q !r"m m%tl

 NM/ N+-------------------- ----------

ram

sam 222tam 333

S7V create tale %"urtl(name $archar2(20',n" numer(0''Tale created

S7V create tale %"urtl2(name $archar2(20',n" numer(0''

Tale created

S7V create tale %"urtl3(name $archar2(20',n" numer(0''

Tale created

S7V create tale %"urtl:(name $archar2(20',n" numer(0''

Tale created

S7V insert all

int" %"urtl $alues(IramuI,'

int" %"urtl2 $alues(IsamuI,22222'

int" %"urtl3 $alues(ItamuI,33333'

int" %"urtl: $alues(IkamuI,:::::'select Q !r"m m%tl here nameIramI

: r"s created

S7V select Q !r"m %"urtl NM/ N+

-------------------- ----------

ramu

S7V select Q !r"m %"urtl2

 NM/ N+

-------------------- ----------

samu 22222

S7V select Q !r"m %"urtl3

 NM/ N+

-------------------- ----------

tamu 33333

S7V select Q !r"m %"urtl:

 NM/ N+

-------------------- ----------

kamu :::::

QQ H"u can use multi tales ith speci!ied !ields, ith duplicate r"s, ith c"nditi"ns, ith !irst and else clausesGROUP BY 

#sing gr"up %, e can create gr"ups "! related in!"rmati"n &"lumns used in select must e used ith gr"up %

"therise it as n"t a gr"up % e9pressi"n

4

Page 50: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 50/238

E1:

S7V select Q !r"m emp

/M)N+ /NM/ +1 MR AR/DT/ S D/)TN+

------------ --------------- ------------------ ------- ---------------- --------- ---------------

<36? SMTA &/RK ;00 <-D/&->0 >000 200

<:?? /N S/SMN ;002 20-G/1->0 3000 300

<;2 =RD S/SMN ;003 22-G/1->0 ;000 ;00

<:?? RM K#MR SRS/SMN ;003 22-N->< 2000;;200

<;66 +N/S MN/R ;002 02-)R->; <;000 200<;2 SM K#MR SRS/SMN ;003 22-N-<; 22000 300

6 r"s selected

S7V select @" !r"m /M) gr"up % @"

+1

--------------------

&/RK 

S/SMN

SRS/SMN

MN/R 

S7V select @",S#M(S' !r"m /M) gr"up % @"

+1 S#M(S'----------------- ----------

&/RK >000

S/SMN >000

SRS/SMN 3:000;;

MN/R <;000

H&!(6

This ill "rk as here clause hich can e used "nl% ith gr"up % ecause "! asence "! here clause in gr"up %

S7V select deptn",@",sum(sal' T"talPSalar%P+!P/achPDept

!r"m emp gr"up % deptn",@" ha$ing sum(sal' V 3000

  D/)TN+ +1 T+TPSRHP+GP/&APD/)T---------- ---- ---------------- -------------------------

  200 MN/R <;000

  200 SRS/SMN 2000;;

  200 &/RK >000

  ;00 S/SMN ;000

  300 SRS/SMN 22000

S7V select deptn",@",sum(sal' T"talPSalar%P"!P/achPDept !r"m emp

gr"up % deptn",@"

ha$ing sum(sal' V 3000

"rder % @"

D/)TN+ +1 T+TPSRHP+GP/&APD/)T

3333333333 33333333333333333 333333333333333333333333200 &/RK >000

200 MN/R <;000

;00 S/SMN ;000

200 SRS/SMN 2000;;

300 SRS/SMN 22000

%S(6 )E,ETE

S7V select Q !r"m /M)/M)N+ /NM/ +1 MR AR/DT/ S D/)TN+

---------- ---------- ------------------ -------- ---------------- -------- ---------------

00 RM &/RK ;00 <-D/&->: >000 30

5

Page 51: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 51/238

002 SM MN/R ;00 -N-> >;000 30

003 SM# S/SMN ;003 0?-G/1->2 >000 302

00: RM# SRS/SMN ;002 22-#N->; :;000 303

S7V D//T/ /M) =A/R/ /NM/ISMI

r" deleted

S7V select Q !r"m /M)

/M)N+ /NM/ +1 MR AR/DT/ S D/)TN+

----------- ------------ ------------- -------- ------------------ ---------- -----------------

00 RM &/RK ;00 <-D/&->: >000 30003 SM# S/SMN ;003 0?-G/1->2 >000 302

00: RM# SRS/SMN ;002 22-#N->; :;000 303

S7V D//T/ /M) =A/R/ /NM/ K/ IRPPI r" deleted

S7V select Q !r"m /M)

/M)N+ /NM/ +1 MR AR/DT/ S D/)TN+

----------- ----------- -------- ------- ---------------- --------- ------------003 SM# S/SMN ;003 0?-G/1->2 >000 302

00: RM# SRS/SMN ;002 22-#N->; :;000 303

S7V D//T/ GR+M /M) =A/R/ /NM/ISM#I

r" deleted

TO )E,ETE &,, RECOR)S

S7V D//T/ GR+M /M)

r" deleted

)E,ETE )%P,C&TE RO9S

S7V S//&T Q GR+M m%T1 NM/ MRK 

--------- ----------

RM 0

RM 0SM 02

SM 02

RM#

RM#SM# 03

SM# 03

SM# 03

TMR ;;;

K 23

2 r"s selected

S7V delete !r"m m%T1 there tr"id V (select min(t2r"D' !r"m m%T1 t2

here tname t2name and tmark t2mark': r"s deleted

S7V S//&T Q GR+M m%T1

 NM/ MRK 

--------- ----------

RM 0

SM 02RM#

5

Page 52: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 52/238

SM# 03

TM

R ;;;

K 23

> r"s selected

  %"in- %P)&TE

S7V select Q !r"m /M)

/M)N+ /NM/ +1 MR AR/DT/ S D/)TN+------------ ------------ ----------- --------- --------------- --------- ------------------00 RM &/RK ;00 <-D/&->: >000 30

002 SM MN/R ;00 -N-> >;000 30

003 SM# S/SMN ;003 0?-G/1->2 >000 302

S7V #)DT/ /M) S/T S ;;;;;,+1 ISRMN/RI =A/R/ /NM/ K/ IRPPI

r" updated

S7V select Q !r"m /M)/M)N+ /NM/ +1 MR AR/DT/ S D/)TN+

---------- -------------- ------------------ -------- ------------- ------- ---------------

00 RM SRMN/R ;00 <-D/&->: ;;;;; 30

002 SM MN/R ;00 -N-> >;000 30003 SM# S/SMN ;003 0?-G/1->2 >000 302

S7V #)DT/ /M) S/T S ;;;;;,+1 ISRMN/RI

3 r"s updated

S7V select Q !r"m /M)

/M)N+ /NM/ +1 MR AR/DT/ S D/)TN+

---------- ----------- ------------------ ------- --------------- --------- -------------00 RM SRMN/R ;00 <-D/&->: ;;;;; 30

002 SM SRMN/R ;00 -N-> ;;;;; 30

003 SM# SRMN/R ;003 0?-G/1->2 ;;;;; 302

RES%,T:

Thus the S7 c"mmands !"r )er!"rming nserti"n, Deleti"n, M"di!%ing, ltering, #pdating an

.ieing rec"rds ased "n c"nditi"ns has een $eri!ied and e9ecuted success!ull%

Creation of !iew"' Snonm"' Se;#ence' nde1e"' Sa5e 2oint.

E1: (o: D= /=.0 VIEWS

  : :  

&M:

5

Page 53: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 53/238

T" create the $ie, e9ecute and $eri!% the $ari"us "perati"ns "n $ies

OBJECT!E:

• .ies Aelps t" encapsulate c"mple9 8uer% and make it reusale

• )r"$ides user securit% "n each $ie - it depends "n %"ur data p"lic% securit%

• #sing $ie t" c"n$ert units - i! %"u ha$e a !inancial data in #S currenc%, %"u can create $ie t"

c"n$ert them int" /ur" !"r $ieing in /ur" currenc%

$ie is n"thing m"re than a S7 statement that is st"red in the dataase ith an ass"ciated name $ie

is actuall% a c"mp"siti"n "! a tale in the !"rm "! a prede!ined S7 8uer%

$ie can c"ntain all r"s "! a tale "r select r"s !r"m a tale $ie can e created !r"m "ne "r man%

tales hich depends "n the ritten S7 8uer% t" create a $ie

.ies, hich are kind "! $irtual tales, all" users t" d" the !"ll"ingB

• Structure data in a a% that users "r classes "! users !ind natural "r intuiti$e

• Restrict access t" the data such that a user can see and (s"metimes' m"di!% e9actl% hat the% need

and n" m"re

&,6ORTHM:

ST/) B Start the DM1S

ST/) 2B &"nnect t" the e9isting dataase(D1'

ST/) 3B &reate the tale ith its essential attriutes

ST/) :B nsert rec"rd $alues int" the tale

ST/) ;B &reate the $ie !r"m the a"$e created tale

ST/) 6B Displa% the data presented "n the ./=

ST/) <B nsert the rec"rds int" the ./=,

ST/) >B &heck the dataase "@ect tale and $ie the inserted $alues presented

ST/) ?B /9ecute di!!erent &"mmands and e9tract in!"rmati"n !r"m the .ie

ST/) 0B St"p the D1MS

COMM&()S E7EC%TO(

CRE&TO( OF T&B,E:

Dataase $ies are created using the CRE&TE !E9 statement .ies can e created !r"m a

single tale, multiple tales, "r an"ther $ie T" create a $ie, a user must ha$e the appr"priate s%stem

 pri$ilege acc"rding t" the speci!ic implementati"n

S7V &R/T/ T1/ EMP,OEE (

5

Page 54: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 54/238

/M)+H//PNM/ .R&AR2(0',

/M)+H//PN+ N#M1/R(>',D/)TPNM/ .R&AR2(0',

D/)TPN+ N#M1/R (;',

DT/P+GP+N DT/

  '

Tale created

T&B,E )ESCRPTO(:

S7V D/S& EMP,OEE

 NM/ N#] TH)/

---------------------------- ------------------------

/M)+H//PNM/ .R&AR2(0'

/M)+H//PN+ N#M1/R(>'

D/)TPNM/ .R&AR2(0'D/)TPN+ N#M1/R(;'

DT/P+GP+N DT/

CRE&TE !E9

S%(T&7 FOR CRE&TO( OF !E9

CREATE ,OR REPLACE- ,FORCE - VIEW .i$/n!0$ ,(co#u0n1n!0$2 co#u0n1n!0$)-AS Qu$%* ,/it& c&$c3 o4tion-5

CRE&TO( OF !E9

S7V &R/T/ ./= EMP!E9 S S//&T /M)+H//PNM/,/M)+H//PN+,

D/)TPNM/,

D/)TPN+,

DT/P+GP+N GR+M EMP,OEE

.ie &reated

)ESCRPTO( OF !E9

S7V D/S& /M)./=

 NM/ N#] TH)/

---------------------- ----------------------------

/M)+H//PNM/ .R&AR2(0'

/M)+H//PN+ N#M1/R(>'D/)TPNM/ .R&AR2(0'

D/)TPN+ N#M1/R(;'

)SP,& !E9:

S7V S//&T Q GR+M /M)./=

/M)+H//PN /M)+H//PN+ D/)TPNM/ D/)TPN+

--------------------- ----------------------- ------------------- ---------------

R. 2: /&/ >?

.H 3:; &S/ 2

R ?> T 22

R 00 &S/ 6<

5

Page 55: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 55/238

(SERTO( OF !&,%ES (TO !E9

R"s "! data can e inserted int" a $ie The same rules that appl% t" the #)DT/ c"mmand als" appl% t

the NS/RT c"mmand Aere, e can n"t insert r"s in &#ST+M/RSP./= ecause e ha$e n"t included all th

 N+T N# c"lumns in this $ie, "therise %"u can insert r"s in a $ie in similar a% as %"u insert them in a tal

(SERT ST&TEME(T S(T&7:

S7V NS/RT NT+ U./=PNM/V (&+#MN NM/, X' .#/S(.#/,X'

COMM&():

S7V NS/RT NT+ /M)./= .#/S (ISRI, 20,I&S/I, 6<,I6-N+.-?>I'

R+= &R/T/D

S7V S//&T Q GR+M /M)./=

/M)+H//PN /M)+H//PN+ D/)TPNM/ D/)TPN+

--------------------- ----------------------- ------------------- --------------

R. 2: /&/ >?

.H 3:; &S/ 2R ?> T 22

R 00 &S/ 6<

SR 20 &S/ 6<

S7V S//&T Q GR+M /M)+H//

/M)+H//PN /M)+H//PN+ D/)TPNM/ D/)TPN+ DT/P+GP

-------------------- ----------------------- ------------------- -------------- -----------------

R. 2: /&/ >? ;-#N-0;

.H 3:; &S/ 2 2-#N-06

R ?> T 22 30-S/)-06

R 00 &S/ 6< :-N+.->

SR 20 &S/ 6< 6-N+.->

)E,ETO( OF !E9:

R"s "! data can e deleted !r"m a $ie The same rules that appl% t" the #)DT/ and NS/RT c"mmands

appl% t" the D//T/ c"mmand

)E,ETE ST&TEME(T S(T&7:

S7V D//T/ U./=PNM/V=A/R/ U&+#MN NM/V .#/

Command:

S7V D//T/ GR+M /M)./= =A/R/ /M)+H//PNM/ISRI

r" deleted

S7V S//&T Q GR+M /M)./=

5

Page 56: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 56/238

/M)+H//PN /M)+H//PN+ D/)TPNM/ D/)TPN+

--------------------- ----------------------- ------------------ ----------------R. 2: /&/ >?

.H 3:; &S/ 2

R ?> T 22

R 00 &S/ 6<

%P)&TE ST&TEME(T:

$ie can e updated under certain c"nditi"nsB

• The S//&T clause ma% n"t c"ntain the ke%"rd DSTN&T

• The S//&T clause ma% n"t c"ntain summar% !uncti"ns

• The S//&T clause ma% n"t c"ntain set !uncti"ns

• The S//&T clause ma% n"t c"ntain set "perat"rs

• The S//&T clause ma% n"t c"ntain an +RD/R 1H clause

• The GR+M clause ma% n"t c"ntain multiple tales

• The =A/R/ clause ma% n"t c"ntain su8ueries

• The 8uer% ma% n"t c"ntain R+#) 1H "r A.N

• &alculated c"lumns ma% n"t e updated

• ll N+T N# c"lumns !r"m the ase tale must e included in the $ie in "rder!"r the NS/RT 8uer% t" !uncti"n

S(T&7:

S7V#)DT/ U./=PNM/V S/TU &+#MN NM/V U&+#MN NM/V CU./=V=A/R/ U&+#MN NM/V.#/

Command:

S7V #)DT/ /M)K../= S/T /M)+H//PNM/IK.I =A/R/ /M)+H//PNM/IR.I

r" updated

S7V S//&T Q GR+M /M)K../=/M)+H//PN /M)+H//PN+ D/)TPNM/ D/)TPN+

--------------------- ----------------------- ------------------- ----------------

K. 2: /&/ >?

.H 3:; &S/ 2

R ?> T 22

R 00 &S/ 6<

)ROP & !E9:

+$i"usl%, here %"u ha$e a $ie, %"u need a a% t" dr"p the $ie i! it is n" l"nger needed

S(T&7:

S7V DR+) ./= U./=PNM/V

E7&MP,E

S7VDR+) ./= /M)./=

$ie dr"ped

CRE&TE & !E9 9TH SE,ECTE) FE,)S:

S(T&7:

5

Page 57: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 57/238

S7V&R/T/ Y+R R/)&/Z ./= U./= NM/VS S//&T U&+#MN NM/VXGR+M

UT1/ NM/V

E7&MP,E3<:

S7V &R/T/ +R R/)&/ ./= /M)P./= S S//&T /M)N+, /NM/,SRH GR+M /M)

S7V S//&T Q GR+M /M)P./=

E7&MP,E3=:

S7V &R/T/ +R R/)&/ ./= /M)P./=2 S S//&T Q GR+M /M) =A/R/ D/)TN+0

S7V S//&T Q GR+M /M)P./=2

(ote:

Replace is the ke%"ard t" a$"id the err"r J"raP00?;Bname is alread% used % an e9isting a@ect

CH&(6(6 THE CO,%M(/S0 (&ME M THE !E9 )%R(6 &S SE,ECT

ST&TEME(T:

TPE3:

S+,L &R/T/ +R R/)&/ ./= /M)PT+TS(/D,NM/,S' S S//&T /M)N+, /NM/,SRH

GR+M /M)

.ie created

/M)N+ /NM/ S RH

----------- -------------- ------------

<36? SMTA 000

<:?? MRK 0;0

<;6; = ;00<6<> +AN >00

<;<> T+M ;00

<;:> T#RN/R ;00

6 r"s selected

.ie created

S7V S//&T Q GR+M /M)PT+TS

/M)N+ /NM/ SRH MRN+ D/)TN+

------------ ------------ ------------- ------------- -------------

<;<> T+M ;00 <2?> 0

<;:> T#RN/R ;00 <2?> 0.ie created

TPE3<:

S7V &R/T/ +R R/)&/ ./= /M)PT+TS S S//&T /M)N+ /D,

/NM/ NM/, SRH S GR+M /M)

S7V S//&T Q GR+M /M)PT+TS

E7&MP,E FOR JO( !E9:

5

Page 58: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 58/238

TPE3=:

S7V &R/T/ +R R/)&/ ./= D/)TP/M) S S//&T /M)N+ /D,

/NM/ /M)NM/,

D/)TN+ DN+,

1DNM/ DPNM/,

1+& DP+&

GR+M /M) ,D/)MT 1 =A/R/ D/)TN+1D/)TN+

S7V S//&T Q GR+M D/)TP/M)

/D NM/ S

-------- ---------- ---------- ----------

<36? SMTA 000

<:?? MRK 0;0

<;6; = ;00

<6<> +AN >00

<;<> T+M ;00

<;:> T#RN/R ;006 r"s selected

.ie created

/D NM/ S

--------- ----------- ----------

<36? SMTA 000

<:?? MRK 0;0

<;6; = ;00

<6<> +AN >00

<;<> T+M ;00

<;:> T#RN/R ;00

6 r"s selected

.ie created

/D /M)NM/ DN+ DPNM/ DP+&

---------- ---------------- ---------- ----------------- ----------------------

<;<> T+M 0 &&+#NT N/= H+RK 

<;:> T#RN/R 0 &&+#NT N/= H+RK 

<36? SMTA 20 S/S &A&+

<6<> +AN 20 S/S &A&+<:?? MRK 30 R/S/R&A O#R&A

<;6; = 30 R/S/R&A O#R&A

!E9 RE&) O(, &() CHEC8 OPTO(:

RE&) O(, C,&%SE:

H"u can create a $ie ith read "nl% "pti"n hich enale "ther t" "nl% 8uer% n" DM "perati"n can e

 per!"rmed t" this t%pe "! a $ie

E7&MP,E3>:

5

Page 59: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 59/238

S7V&R/T/ +R R/)&/ ./= /M)PN+PDM S S//&T Q GR+M /M) =TA R/D +NH

9TH CHEC8 OPTO( C,&%SE:

E7&MP,E3>:

S7V &R/T/ +R R/)&/ ./= /M)P&KP+)T+N S S//&T /M)N+, /NM/, SRH, D/)TN+

GR+M /M) =A/R/ D/)TN+0 =TA &A/&K +)T+N

S7V S//&T Q GR+M /M)P&KP+)T+N

JO( !E9:

E7&MP,E3?:

S7V &R/T/ +R R/)&/ ./= D/)TP/M)P./= S S//&T /M)N+,

  /NM/,

  D/)TN+,

  1DNM/,

1+&

GR+M /M) , D/)MT 1

=A/R/ D/)TN+1D/)TN+

S7V S//&T Q GR+M D/)TP/M)P./=

.ie created

/M)N+ /NM/ SRH D/)TN+

----------- ------------- --------------- --------------

<;<> T+M ;00 0

<;:> T#RN/R ;00 0

.ie created

/M)N+/NM/D/)TN+ DNM/ +&

----------- ------------ ------------- ------------- -------

<;<> T+M 0 &&+#NT N/= H+RK <;:> T#RN/R 0 &&+#NT N/= H+RK 

<36? SMTA 20 S/S &A&+

<6<> +AN 20 S/S &A&+

<:?? MRK 30 R/S/R&A O#R&A<;6; = 30 R/S/R&A O#R&A

6 r"s selected

FORCE !E9:

E7&MP,E3@:

S7V &R/T/ +R R/)&/ G+R&/ ./= MH./= S S//&T Q GR+M EHO

S7V S//&T Q GR+M MH./=

S7V &R/T/ T1/ EHO S S//&T /M)N+,/NM/,SRH,D/)TN+ GR+M /M)

5

Page 60: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 60/238

S7V S//&T Q GR+M EHO

S7V &R/T/ +R R/)&/ G+R&/ ./= MH./= S S//&T Q GR+M EHO

S7V S//&T Q GR+M MH./=

=arningB .ie created ith c"mpilati"n err"rs

S//&T Q GR+M MH./=

Q

/RR+R at line B

+R-0:063B $ie :03?MH./= has err"rs

Tale created

/M)N+ /NM/ SRH D/)TN+

---------- -------------------- ---------- ---------- -----------------<36? SMTA 000 20

<:?? MRK 0;0 30

<;6; = ;00 30

<6<> +AN >00 20

<;<> T+M ;00 0<;:> T#RN/R ;00 0

6 r"s selected

.ie created

/M)N+ /NM/ SRH D/)TN+

----------- ------------- ------------- ---------------

<36? SMTA 000 20

<:?? MRK 0;0 30

<;6; = ;00 30

<6<> +AN >00 20

<;<> T+M ;00 0

<;:> T#RN/R ;00 06 r"s selected

COMP,(6 & !E9:

S(T&7:

T/R ./= U./=PNM/V &+M)/

E7&MP,E:

S7V T/R ./= MH./= &+M)/

6

Page 61: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 61/238

Page 62: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 62/238

S%n"n%ms are "!ten used !"r securit% and c"n$enience G"r e9ample, the% can d" the !"ll"ingB

• Mask the name and "ner "! an "@ect

• )r"$ide l"cati"n transparenc% !"r rem"te "@ects "! a distriuted dataase

• Simpli!% S7 statements !"r dataase users

• /nale restricted access similar t" specialiFed $ies hen e9ercising !ine-grained access c"ntr"l

H"u can create "th pulic and pri$ate s%n"n%ms 2#$lic s%n"n%m is "ned % the special user gr"up

named )#1& and e$er% user in a dataase can access it 2ri5ate s%n"n%m is in the schema "! a speci!i

user h" has c"ntr"l "$er its a$ailailit% t" "thers

&,6ORTHM:

ST/) B Start the DM1S

ST/) 2B &"nnect t" the e9isting dataase(D1'ST/) 3B &reate the tale ith its essential attriutes

ST/) :B nsert rec"rd $alues int" the tale

ST/) ;B &reate the s%n"n%ms !r"m the a"$e created tale "r an% data "@ect

ST/) 6B Displa% the data presented "n the s%n"n%ms

ST/) <B nsert the rec"rds int" the s%n"n%ms,

ST/) >B &heck the dataase "@ect tale and $ie the inserted $alues presented

ST/) ?B St"p the D1MS

E1am2le:

Snta1:

S+,LCRE&TE S(O(M s%n"n%mName FOR  "@ect

+R 

S+,L&R/T/ SHN+NHM tt !"r te"tI

Dependent +@ect - tt (SHN+NHM NM/ '

Re!erenced +@ect - te"t (T1/ NM/'

%S&6E:

• #sing emp %"u can per!"rm DM "perati"n as %"u ha$e create s%sn"nm !"r tale "@ect !

empl"%ees tale is dr"pped then status "! emp ill e in$alid

• "cal Dependencies are aut"maticall% managed % "racle ser$er

6

Page 63: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 63/238

COMM&()S:

CRE&TE THE T&B,E

S7V &R/T/ T1/ studentPtale(RegPN" numer(;',NM/ $archar2(;',MRK numer(3''

Tale created

(SERT THE !&,%ES (TO THE T&B,E

S7V insert int" studentPtale $alues(000,IramI,>;'

r" created

S7V insert int" studentPtale $alues(0002,IsamI,<;'

r" created

S7V insert int" studentPtale $alues(0003,IsamuI,?;'

r" created

S7V select Q !r"m ST#D/NTPT1/

R/PN+ NM/ MRK 

------------ --------- ----------

000 ram >;

0002 sam <;

0003 samu ?;

CRE&TE THE S(O(M FROM T&B,E

S7V &R/T/ SHN+NHM ST#D/NTPSHN+NHM G+R ST#D/NTPT1/

S%n"n%m created

)SP,& THE !&,%ES OF T&B,E B %S(6 THE SS(O(M

S7V select Q !r"m ST#D/NTPSHN+NHM

R/PN+ NM/ MRK 

------------ ------------- ----------

000 ram >;

0002 sam <;

0003 samu ?;

(SERT THE !&,%ES TO THE S(O(M

6

Page 64: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 64/238

S7V insert int" studentPSHN+NHM $alues(0006,IRI,>0'

r" created

)SP,& THE !&,%ES ( BOTH T&B,E &() S(O(M

S7V select Q !r"m ST#D/NTPT1/

R/PN+ NM/ MRK 

------------ ----------- ----------

000 ram >;

0002 sam <;

0003 samu ?;

0006 R >0

S7V select Q !r"m ST#D/NTPSHN+NHMR/PN+ NM/ MRK 

----------- --------- ---------

000 ram >;

0002 sam <;

0003 samu ?;

0006 R >0

O% C&( %P)&TE THE T&B,E B %S(6 S(O(M

S7V #)DT/ ST#D/NTPSHN+NHM S/T MRK00 =A/R/ R/PN+0006

r" updated

S7V select Q !r"m ST#D/NTPSHN+NHM

R/PN+ NM/ MRK 

------------ ----------- ----------------

000 ram >;

0002 sam <;

0003 samu ?;

0006 R 00

S7V select Q !r"m ST#D/NTPT1/

R/PN+ NM/ MRK 

------------ ------------- ---------

000 ram >;

0002 sam <;

0003 samu ?;

6

Page 65: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 65/238

Page 66: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 66/238

• =hether the se8uence ascends "r descends

• The inter$al eteen numers

• =hether +racle Dataase sh"uld cache sets "! generated se8uence numers in mem"r%

&,6ORTHM:

Step B Start the DM1S

Step 2B &"nnect t" the e9isting dataase (D1'

Step 3B &reate the se8uence ith its essential "pti"nal parameter

Step :B Displa% the data presented "n the se8uence % using pseud" c"lumn

Step ;B lter the se8uence ith di!!erent "pti"nal parameter

Step 6B Dr"p the se8uence

Step <B St"p the D1MS

Creatin- a Se;#ence

H"u create a se8uence using the &R/T/ S/7#/N&/ statement, hich has the !"ll"ing

S(T&7:

S+,LCRE&TE SE+%E(CE se8uencePname

YST&RT 9TH startPnumZ

Y(CREME(T B incrementPnumZ

Y [ M&7!&,%E ma9imumPnum ^ (OM&7!&,%E \ Z

Y [ M(!&,%E minimumPnum ^ (OM(!&,%E \ Z

Y [ CC,E ^ (OCC,E \ Z

Y [ C&CHE cachePnum ^ (OC&CHE \ Z

Y [ OR)ER  ^ (OOR)ER  \ Z

=here

•   sequence_name is the name "! the se8uence

•   start_num is the integer t" start the se8uence The de!ault start numer is

6

Page 67: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 67/238

•   increment_num is the integer t" increment the se8uence % The de!ault increment numer is Th

as"lute $alue "! increment_num must e less than the di!!erence eteen maximum_num an

minimum_num

•   maximum_num is the ma9imum integer "! the se8uence maximum_num must e greater than "

e8ual t" start_num, and maximum_num must e greater than minimum_num

• (OM&7!&,%E speci!ies the ma9imum is 02< !"r an ascending se8uence "r * !"r a descendin

se8uence N+ME.#/ is the de!ault

•   minimum_num is the minimum integer "! the se8uence minimum_num must e less than "r e8ual t

 start_num, and minimum_num must e less than maximum_num

• (OM(!&,%E speci!ies the minimum is !"r an ascending se8uence "r *026 !"r a descendin

se8uence N+MN.#/ is the de!ault

• CC,E means the se8uence generates integers e$en a!ter reaching its ma9imum "r minimum $alue

=hen an ascending se8uence reaches its ma9imum $alue, the ne9t $alue generated is the minimum=hen a descending se8uence reaches its minimum $alue, the ne9t $alue generated is the ma9imum

• (OCC,E means the se8uence cann"t generate an% m"re integers a!ter reaching its ma9imum "

minimum $alue N+&H&/ is the de!ault

•   cache_num is the numer "! integers t" keep in mem"r% The de!ault numer "! integers t" cache i

20 The minimum numer "! integers that ma% e cached is 2 The ma9imum integers that ma%

cached is determined % the !"rmula &/(maximum_num - minimum_num'41S(increment_num'

• (OC&CHE means n" caching This st"ps the dataase !r"m pre-all"cating $alues !"r the se8uence

hich pre$ents numeric gaps in the se8uence ut reduces per!"rmance aps "ccur ecause cache

$alues are l"st hen the dataase is shut d"n ! %"u "mit &&A/ and N+&&A/, the dataas

caches 20 se8uence numers % de!ault

• OR)ER  guarantees the integers are generated in the "rder "! the re8uest H"u t%picall% use +RD/R

hen using Real pplicati"n &lusters, hich are set up and managed % dataase administrat"rs

(OOR)ER  d"esnt guarantee the integers are generated in the "rder "! the re8uest N++RD/R 

is the de!ault

E1am2le:

Command:

S7V &R/T/ S/7#/N&/ se8N&R/M/NT 1H

STRT ith

ME.#/ ;

MN.#/ 0

Se;#ence created.

6

Page 68: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 68/238

Page 69: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 69/238

alter S/7#/N&/ se8

ma9$alue 2;

N&R/M/NT 1H 2

c%cle

cache 2

dr"p S/7#/N&/ se8

E7&MP,E: <

&R/T/ S/7#/N&/ se82

N&R/M/NT 1H

start ith

ma9$alue ;

min$alue 0

c%cle

&&A/ :

E7&MP,E: =

&R/T/ S/7#/N&/ se83

N&R/M/NT 1H -

start ith 2

ma9$alue ;

min$alue 0

E7&MP,E: >

&R/T/ S/7#/N&/ se83

N&R/M/NT 1H -

start ith 2

ma9$alue ;

min$alue 0

c%cle

cache :

E7&MP,E: ?

&R/T/ S/7#/N&/ se8

N&R/M/NT 1H

start ith

ma9$alue 0

min$alue 0

6

Page 70: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 70/238

Page 71: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 71/238

nde1

The inde9es are special "@ects hich uilt "n t"p "! tales The inde9es can d" "perati"n lik

S//&T , D//T/ and #)DT/ statement !aster t" manipulate a large am"unt "! data n ND/E ca

als" e called a tale and it has a data structure n ND/E is created "n c"lumns "! a tale +ne tale ma%

c"ntain "ne "r m"re ND/E tales

The S+, ()E7 doe" the followin-:

• ND/E/S can l"cate in!"rmati"n ithin a dataase $er% !ast

• n ND/E makes a catal"g "! r"s "! a dataase tale as r" can e p"inted ithin a !racti"n "!

time ith a minimum e!!"rt

• tale ND/E is a dataase structure hich arranges the $alues "! "ne "r m"re c"lumns in a

speci!ic "rder

• The per!"rmance "! an ND/E can n"t e rec"gniFed much hen dealing ith relati$el% small

tales

• ND/E can "rk pr"perl% and 8uickl% !"r the c"lumns that ha$e man% di!!erent $alues

t takes a l"ng time t" !ind an in!"rmati"n !"r "ne "r c"minati"n "! c"lumns !r"m a tale henthere are th"usands "! rec"rds in the tale n that case i! inde9es are created "n that c"lumns, hich

are accessed !re8uentl%, the in!"rmati"n can e retrie$ed 8uickl%

• The ND/E !irst s"rts the data and then it assigns an identi!icati"n !"r each r"

• The ND/E tale ha$ing "nl% t" c"lumns, "ne is a r"id and an"ther is inde9ed-c"lumn ("rdered

• =hen data is retrie$ed !r"m a dataase tale ased "n the inde9ed-c"lumn, the inde9 p"inter

searches the r"id and 8uickl% l"cates that p"siti"nin the actual tale and displa% the r"s s"ught

!"r

7

Page 72: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 72/238

How it differ from 5iew

• n ND/E is als" a tale S" it has a data structure

• ND/E/S are p"inters that represents the ph%sical address "! a data

• n ND/E is created "n c"lumns "! a tale

• n ND/E makes a catal"g ased "n "ne "r m"re c"lumns "! a tale

• +ne tale ma% c"ntain "ne "r m"re ND/E tales

• n ND/E can e created "n a single c"lumn "r c"minati"n "! c"lumns "! a dataase tale

T2e" of nde1e":

Simple nde9

2 &"mp"site nde9

Command

S&MP,E T&B,E:

S7V S//&T Q GR+M ST#D/NTPT1

SPN+ R/PN+ NM/ S/E D+1 T+TP)/R&/NT/ M+1/PN+ DDR/SS 1++D

--------- ------------ -------------------- ------ ----------- ------------------------------- ----------------- ------------- ------- 000 RM M -D/&->; <; ?<;6:3;<>? )+TN"B3046 1& 1C

2 0002 R M 6-N-<: ><; ?:;6:3;:;> 1& Nager +C3 0003 NRM G 22-G/1->< ?;; ?:63;: SKTA Nager C

: 000: nitha G 0;-MR->< 6:3 ?:63;;;; NN Nager 1

Sim2le nde1:

=hen inde9 is created "n "ne c"lumn it is called as simple inde9

Snta1:

&R/T/ ND/E UND/EPNM/V +N UT1/PNM/V (&+PNM/'

E1:

S7V create inde9 m%nde9 "n studentPtl(name'

nde9 created

note"

• nde9 sh"uld e created "n c"lumns hich e regularl% use in the here clause

=hen a inde9 is created a separate structure is created ith !irst c"lumn is R+=D and sec"ndc"lumn as inde9ed c"lumn

• The R"s in the inde9 ill e arranged in the ascending "rder "! inde9ed c"lumn

Com2o"ite nde1:

hen nde9 is created multiple c"lumns it is called c"mp"site inde9

E1:

7

Page 73: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 73/238

S7V create inde9 m%&"mpnde9 "n studentPtl(D+1,DDR/SS'

nde9 created

The a"$e inde9 mCom2nde1 is used "nl% hen "th the c"lumns are used in the here clause

)i"ad5anta-e" of inde1:

• nde9 ill c"nsume mem"r%

• The per!"rmance "! DM c"mmand ill e decreased

nde9 can als" e categ"riFed t" t%pesB

#ni8ue inde9

2 N"n-uni8ue inde9

%ni;#e nde1:

• ! the inde9ed c"lumn c"ntains uni8ue $alue it is called uni8ue inde9

• uni8ue inde9 is aut"maticall% created =hen e create a tale ith primar% ke% c"nstraint "r

uni8ue c"nstraint

Cmd

S7V create uni8ue inde9 m%nde9 "n studentPtl(name'

(on3#ni;#e inde1:

! an inde9 c"lumn c"ntains duplicated $alues the% are called as n"n-uni8ue inde9

See to inde1 ta$le":

S7V Select inde9Pname !r"m userPinde9es

ND/EPNM/

-----------------------

MH&+M)ND/E

MHND/E

SHSP&006:

7

Page 74: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 74/238

7uer% t" see list "! all the inde9es

S7V Select ND/EPNM/,T1/PNM/ !r"m userPinde9es

ND/EPNM/ T1/PNM/

------------------------------ ------------------------------

SHSP&006: T1P)K/H

MH&+M)ND/E ST#D/NTPT1MHND/E ST#D/NTPT1

7uer% t" see list "! all the inde9es al"ng ith c"lumn name

S7V Select inde9Pname, talePname, c"lumnPname !r"m userPindPc"lumns

ND/EPNM/ T1/PNM/ &+#MNPNM/

-------------------- ------------------- ------------------------MH&+M)ND/E ST#D/NTPT1 DDR/SS

MH&+M)ND/E ST#D/NTPT1 D+1

MHND/E ST#D/NTPT1 NM/.

S7V Desc userPinde9es

S7V Desc userPindPc"lumns

F#nction $a"ed inde1:

=hen inde9 is created % using !uncti"ns it is called as !uncti"n ased inde9

E1:

S7V &R/T/ ND/E m%Guncnde9 +N ST#D/NTPT1(l"er(name''

nde9 created

To dro2 on inde1:

E1:

S7V dr"p inde9 inde9P"!PstudentPtl

7

Page 75: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 75/238

RES%,T:

Thus the S7 c"mmands !"r creati"n and $ari"us "perati"ns "n nde9es has een $eri!ied and

e9ecuted success!ull%

S&!E PO(T

E1: (o: D= /=.?0

  : :  

&M:

T" create the S./ )+NT !"r the transacti"n and $eri!% the $ari"us "perati"ns "! T& c"mmands

OBJECT!E:

The S&!EPO(T statement names and marks the current p"int in the pr"cessing "! a transacti"n

=ith the RO,,B&C8 TO statement, sa$ep"ints und" parts "! a transacti"n instead "! the h"l

transacti"n

n implicit sa$ep"int is marked e!"re e9ecuting an (SERT' %P)&TE' or )E,ETE statement

the statement !ails, a r"llack t" the implicit sa$ep"int is d"ne N"rmall%, @ust the !ailed S7 statement i

r"lled ack, n"t the h"le transacti"n i! the statement raises an unhandled e9cepti"n, the h"st en$ir"nment

&,6ORTHM:

ST/) B Start the DM1S

ST/) 2B &"nnect t" the e9isting dataase (D1'

ST/) 3B &reate the tale ith its essential attriutes

7

Page 76: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 76/238

ST/) :B nsert rec"rd $alues int" the tale "r per!"rm an% kind "! DM "perati"n

ST/) ;B &reate the S&!E PO(Ts !"r s"me set "! statement "n the transacti"n "! dataase "@ect

ST/) 6B #se the COMMT c"mmand t" sa$e the e!!ect "! the pre$i"us c"mmand "perati"n e9cept DD

c"mmand

ST/) <B #se the RO,,B&C8 TO SP,&B,E 4 RO,,B&C8  c"mmand !"r rest"re the dataase status

up t" the sa$e p"int

ST/) >B &heck the status "! the dataase

ST/) ?B St"p the D1MS

Snta1B

S./)+NTUS./)+NTPNM/V

E1B

S7V create tale +RD/RP)R+&/SSN(

+rderPD numer(3',

)r"ductPD $archar2(0',

7uantit% numer(3,2',

)rice numer(:,2'

'

Ta$le created.

S7V insert int" +RD/RP)R+&/SSN $alues(0,IR&/-22I,I6;I,I30;0I'

row created.

S7V insert int" +RD/RP)R+&/SSN $alues(02,I+I,I20I,I?0;0I'

row created.

S7V S//&T Q GR+M +RD/RP)R+&/SSN

+RD/RPD )R+D#&TPD 7#NTTH )R&/

-------------- ---------------- -------------- ----------

0 R&/-22 6; 30;

02 + 2 ?0;

S7V COMMTI

Commit com2lete

7

Page 77: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 77/238

S7V insert int" +RD/RP)R+&/SSN $alues(03,I1SI,I2I,I?;I'

row created.

S7V insert int" +RD/RP)R+&/SSN $alues(0:,I=T/R 1+TSI,I2I,I20I'

row created.

S7V S&!EPO(T &I

Sa5e2oint created.

S7V insert int" +RD/RP)R+&/SSN $alues(0;,I/I,I>I,I:0;0I'

row created.

S7V insert int" +RD/RP)R+&/SSN $alues(06,ISAM)++I,II,I<;;0I'

row created.

S7V S&!EPO(T BI

Sa5e2oint created.

S7V insert int" +RD/RP)R+&/SSN $alues(0<,I1R S+)I,II,I:;;0I'

row created.

S7V insert int" +RD/RP)R+&/SSN $alues(0>,IT+N/RI,II,I<;;0I'

row created.

S7V S&!EPO(T CI

Sa5e2oint created.

S7V insert int" +RD/RP)R+&/SSN $alues(0?,IS#RI,I20I,I60;0I'

row created.

S7V S//&T Q GR+M +RD/RP)R+&/SSN

+RD/RPD )R+D#&TPD 7#NTTH )R&/

-------------- ---------------- --------------- ----------

0 R&/-22 6; 30;

02 + 2 ?0;

03 1S 2 ?;

7

Page 78: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 78/238

0: =T/R 1+TS 2 20

0; / > :0;

06 SAM)++ <;;

0< 1R S+) :;;

0> T+N/R <;;

0? S#R 2 60;

? r"s selected

S7V R+1&K T+ 1

Roll$ack com2lete.

S7V S//&T Q GR+M +RD/RP)R+&/SSN

+RD/RPD )R+D#&TPD 7#NTTH )R&/---------------- ------------------- -------------- -------------

0 R&/-22 6; 30;

02 + 2 ?0;

03 1S 2 ?;

0: =T/R 1+TS 2 20

0; / > :0;

06 SAM)++ <;;

6 r"s selected

S7V R+1&K T+

Roll$ack com2lete.

S7V S//&T Q GR+M +RD/RP)R+&/SSN

+RD/RPD )R+D#&TPD 7#NTTH )R&/

---------------- -------------------- ---------------- ------------

0 R&/-22 6; 30;

02 + 2 ?0;

03 1S 2 ?;

0: =T/R 1+TS 2 20

S7V R+1&K

Roll$ack com2lete.

7

Page 79: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 79/238

S7V S//&T Q GR+M +RD/RP)R+&/SSN

+RD/RPD )R+D#&TPD 7#NTTH )R&/

--------------- -------------------- ---------------- -------------

0 R&/-22 6; 30;

02 + 2 ?0;

S7V R+1&K

Roll$ack com2lete.

S7V S//&T Q GR+M +RD/RP)R+&/SSN

+RD/RPD )R+D#&TPD 7#NTTH )R&/

---------------- ------------------- ---------------- -----------

0 R&/-22 6; 30;

02 + 2 ?0;

7

Page 80: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 80/238

RES%,T:

Thus the S7 c"mmands !"r creati"n and $ari"us "perati"ns "n transacti"n (T& &+MMND'

sa$e p"int has een $eri!ied and e9ecuted success!ull%

Creatin- an Em2loee data$a"e to "et 5ario#" con"traint" in R)BMS

E1: (o: D>

  : :  

&M:

t the end "! this e9ercise students are ale

• T" di!!erentiate eteen sel! re!erential c"nstraints and !"reign ke% c"nstraint

• T" re!er a !ield "! a gi$en tale "r an"ther tale % using !"reign ke%

• T" appl% check c"nstraint 5 de!ault c"nstraint in an e!!ecti$e manner

&,6ORTHM:

ST/) B Start the DM1S

ST/) 2B &"nnect t" the e9isting dataase (D1'

ST/) 3B &reate the tale ith its essential c"nstraint

ST/) :B nsert rec"rd $alues int" the tale and then check the c"nstraint

ST/) ;B disale the c"nstraints and insert the $alues int" the tale

ST/) 6B i! %"u ant t" re-enale the c"nstraint then enale %"u can d"

ST/) <B St"p the D1MS

8

Page 81: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 81/238

CO(STR&(TS

&"nstraints are part "! the tale de!initi"n that limits and restricti"n "n the $alue entered int" its

c"lumns

(TE6RT CO(STR&(T

n integrit% c"nstraint is a mechanism used % "racle t" pre$ent in$alid data entr% int" the tale t has

en!"rcing the rules !"r the c"lumns in a tale

The t%pes "! the integrit% c"nstraints areB

a' D"main ntegrit%

 ' /ntit% ntegrit%

c' Re!erential ntegrit%

TPES OF CO(STR&(TS:

' )rimar% ke%

2' G"reign ke%4re!erences

3' &heck 

:' #ni8ue

;' N"t null

6' Null

<' De!ault

CO(STR&(TS C&( BE CRE&TE) ( THREE 9&S:

8

Page 82: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 82/238

Page 83: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 83/238

OR&3DDDD: #ni;#e con"traint /SE(TH,.SSCDD@?D0 5iolated

S7V insert int" T1P)K/H $alues(0003,IRI,>;'

row created.

S7V select Q GR+M T1P)K/H

R/N+ NM/ NHPS#1PMRK  

----------- ------------- -----------------------------

000 ra@u <;

0002 ra@ >;0 Ka@ 22

0003 R >;

Col#mn le5el con"traint" #"in- 2rimar ke with namin- con5ention:

+%ER: >

7: =rite a 8uer% t" create primar% c"nstraints ith c"lumn le$el ith naming c"n$enti"n

Snta1: s%nta9 !"r c"lumn le$el c"nstraints using primar% ke%

S7 V&R/T/ U+1TH)/VU+1NM/V (

&+ NM/ UDTTH)/V (SO/'&+NSTRNTS UNM/ +G &+NSTRNTSVUTH)/ +G &+NSTRNTSV,

&+ NM/2 UDTTH)/V (SO/'XXXXXXXXXXXXXXX'Command:

S7V&R/T/ T1/ /M)+H// (

/M)N+ N#M1/R (:' CO(STR&(T EMPEMP(OP8 PRM&R 8E'

/NM/.R&AR2 (0',+1 .R&AR2 (6',S N#M1/R (;',D/)TN+ N#M1/R (<''

Ta$le le5el 2rimar ke con"traint":

+%ER: ?

7; =rite a 8uer% t" create primar% c"nstraints ith tale le$el ith naming c"n$enti"n

Snta1: The s%nta9 !"r tale le$el c"nstraints using primar% ke%

S7B V&R/T/ U+1TH)/VU+1NM/V (&+#MN NM/ UDTTH)/V (SO/',

&+#MN NM/ UDTTH)/V (SO/',

&+NSTRNTS UNM/ +G TA/ &+NSTRNTSVUTH)/ +G TA/ &+NSTRNTSV'

Command:

S7V&R/T/ T1/ /M)+H// (/M)N+ N#M1/R(6',/NM/ .R&AR2(20',+1 .R&AR2(6',

S N#M1/R(<', D/)TN+ N#M1/R(;',

CO(STR&(T EMPEMP(OP8 PRM&R 8E/EMP(O00I

Ta$le le5el con"traint with alter command /2rimar ke0:

+%ER: @

76 =rite a 8uer% t" create primar% c"nstraints ith alter c"mmand

Snta1: The s%nta9 !"r c"lumn le$el c"nstraints using primar% ke%

S7BV&R/T/ U+1TH)/VU+1NM/V (&+#MN NM/ UDTTH)/V(SO/',

&+#MN NM/ UDTTH)/V (SO/''

 ORU

8

Page 84: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 84/238

S7V T/R T1/ UT1/ NM/V DD &+NSTRNTS UNM/ +G TA/&+NSTRNTSV UTH)/ +G

TA/ &+NSTRNTSVU&+#MN NM/V'

Command:

S7V&R/T/ T1/ /M)+H//(/M)N+ N#M1/R(;',/NM/ .R&AR2(6',+1 .R&AR2(6',

S N#M1/R(6',D/)TN+ N#M1/R(6''

S7VT/R T1/ /M)3 DD &+NSTRNT EMP=EMP(OP8 PRM&R8E /EMP(O0I

REFERE(CE 4FORE6( 8E CO(STR&(T

t en!"rces relati"nship eteen tales T" estalish parent-child relati"nship eteen 2 tales ha$ing

c"mm"n c"lumn de!initi"n, e make use "! this c"nstraint T" implement this, e sh"uld de!ine the c"lumn in th

 parent tale as primar% ke% and same c"lumn in the child tale as !"reign ke% re!erring t" the c"rresp"nding paren

entr%

Forei-n ke

c"lumn "r c"minati"n "! c"lumn included in the de!initi"n "! re!erential integrit%, hich "uld re!er t" a

re!erenced ke%

Referenced ke

t is a uni8ue "r primar% ke% up"n hich is de!ined "n a c"lumn el"nging t" the parent tale

Col#mn le5el forei-n ke con"traint

+%ER: A

7< =rite a 8uer% t" create !"reign ke% c"nstraints ith c"lumn le$el

Parent Ta$le:

Snta1: S%nta9 !"r &"lumn le$el c"nstraints #sing )rimar% ke%

S7BV&R/T/ U+1TH)/VU+1NM/V (

&+#MN NM/ UDTTH)/V(SO/'UTH)/ +G &+NSTRNTSV ,

&+#MN NM/ UDTTH)/V (SO/'XXXXXXXXX'

Command:

S7V &R/T/ T1/ )EPT(

)EPT(O N#M1/R(3' PRM&R 8E,

)(&ME .R&AR2(20',,OC&TO( .R&AR2(;''

Tale created

S7V desc D/)T

 Name Null] T%pe ----------------- ---------------- --------------------

D/)TN+ N+T N# N#M1/R(3'

 DNM/ .R&AR2(20'

 +&T+N .R&AR2(;'

S7V select Q !r"m D/)T

D/)TN+ DNM/ +&T+N

------------ ---------------- ---------------

8

Page 85: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 85/238

0 kamal chennai

02 ra@ini madurai

03 @ith k"$ai

Child Ta$le:

Snta1: The s%nta9 !"r c"lumn le$el c"nstraints using !"reign ke%

S7BV&R/T/ U+1TH)/VU+1NM/V (&+#MN NM/ UDTTH)/V(SO/',

&+#MN NM/2 UDTTH)/V (SO/' R/G/R/N&/S UT1/ NM/V(&+#MN NM/V X'

Command:

S7V &R/T/ T1/ EMP,(EMP(O N#M1/R(:',)EPT(O N#M1/R(3' REFERE(CES D/)T()EPT(O',

)ES6( .R&AR2(0''Tale created

S7V desc /M)

 Name Null] T%pe

-------------------------- ------------- ----------------------------

/M)N+ N#M1/R(:'

D/)TN+ N#M1/R(3'

D/SN .R&AR2(0'

S7V insert int" /M) $alues(;00,0,IRI'

r" created

S7V insert int" /M) $alues(;003,03,IKI'

r" created

S7V insert int" /M) $alues(;006,0:,IRMHI'

insert int" /M) $alues(;006,0:,IRMHI'

Q

/RR+R at line B+R-022?B integrit% c"nstraint (SHST/MSHSP&002?:' $i"lated - parent ke% n"t

!"und

S7V select Q !r"m /M)/M)N+ D/)TN+ D/SN

---------- ------------ -------------

;00 0 R

;003 03 K

Col#mn le5el forei-n ke con"traint with namin- con5er"ion"

+%ER:

7> =rite a 8uer% t" create !"reign ke% c"nstraints ith c"lumn le$el

Parent Ta$le:

Snta1: The s%nta9 !"r c"lumn le$el c"nstraints using primar% ke%

S7 BV &R/T/U+1TH)/VU+1NM/V (&+#MN NM/ UDTTH)/V(SO/'UTH)/ +G

&+NSTRNTSV,&+#MN NM/ UDTTH)/V (SO/'X'

Child Ta$le:

Snta1: "%nta9 !"r c"lumn le$el c"nstraints using !"reign ke%

S7 BV &R/T/U+1TH)/VU+1NM/V (&+#MN NM/ UDTTH)/V(SO/' ,

8

Page 86: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 86/238

&+#MN NM/2 UDTTH)/V (SO/' CO(STR&(T CO(ST.(&MELR/G/R/N&/S UT1/ NM/V

(&+#MN NM/VX'

Command:

S7V&R/T/ T1/ D/)T (D/)TN+ N#M1/R (2' PRM&R8E,

DNM/ .R&AR2 (20', +&T+N .R&AR2 (;''

S7V&R/T/ T1/ /M): (/M)N+ N#M1/R (3',

D/)TN+ N#M1/R (2' CO(STR&(T EMP>&)EPT(OF8 REFERE(CES )EPT /)EPT(O0'

D/SN .R&AR2 (0''

Ta$le le5el forei-n ke con"traint":

+%ER:

7? =rite a 8uer% t" create !"reign ke% c"nstraints ith Tale le$el

Parent Ta$le:

Snta1:

S7 BV &R/T/U+1TH)/VU+1NM/V (&+#MN NM/ UDTTH)/V(SO/' UTH)/ +G

&+NSTRNTSV, &+#MN NM/ UDTTH)/V (SO/'X'

Child Ta$le:

Snta1: The s%nta9 !"r tale le$el c"nstraints using !"reign ke%

S7 BV &R/T/U+1TH)/VU+1NM/V (&+#MN NM/ UDTTH)/V(SO/',

&+#MN NM/2 UDTTH)/V (SO/',

CO(STR&(T CO(ST.(&MELR/G/R/N&/S UT1/ NM/V (&+#MN NM/V'

Command:

S7V&R/T/ T1/ D/)T(D/)TN+ N#M1/R(2' PRM&R 8E,

DNM/ .R&AR2(20',+&T+N .R&AR2(;''

S7V&R/T/ T1/ /M);(/M)N+ N#M1/R(3',D/)TN+ N#M1/R(2',

D/SN .R&AR2(0' CO(STR&(T E(P<)EPT(OF8 FORE6(8E/)EPT (O0 REFERE(CES

)EPT/)EPT(O00I

Ta$le le5el forei-n ke con"traint" with alter command:

+%ER:<D

720 =rite a 8uer% t" create !"reign ke% c"nstraints ith Tale le$el ith alterc"mmand

Parent Ta$le:

Snta1:

S7 BV&R/T/U+1TH)/VU+1NM/V (&+#MN NM/ UDTTH)/V(SO/'UTH)/ +G

&+NSTRNTSV , &+#MN NM/ UDTTH)/V (SO/' XXXXXXXXXXXX'

Child Ta$le:

Snta1: The s%nta9 !"r tale le$el c"nstraints using !"reign ke%

S7BV&R/T/ U+1TH)/VU+1NM/V (&+#MN NM/ UDTTH)/V(SO/',

&+#MN NM/2 UDTTH)/V (SO/''

8

Page 87: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 87/238

Snta1:

S7V T/R T1/ UT1/ NM/V DD &+NSTRNT U&+NST NM/VR/G/R/N&/S UT1/ NM/V(&+#MN NM/V'

Command:

S7V&R/T/ T1/ D/)T(D/)TN+ N#M1/R(2' )RMRH K/H, DNM/ .R&AR2(20', +&T+N .R&AR2(;''

S7V&R/T/ T1/ /M); (/M)N+ N#M1/R(3', D/)TN+ N#M1/R (2', D/SN .R&AR2 (0''S7VT/R T1/ /M)6 DD &+NSTRNT /M)6PD/)TN+PGK G+R/NK/H(D/)TN+'R/G/R/N&/S

D/)T(D/)TN+'

CHEC8 CO(STR&(T

&heck c"nstraint can e de!ined t" all" "nl% a particular range "! $alues hen the manipulati"n $i"lates th

c"nstraint, the rec"rd ill e re@ected &heck c"nditi"n cann"t c"ntain su 8ueries

Col#mn le5el check" con"traint:

+%ER: <

72 =rite a 8uer% t" create &heck c"nstraints ith c"lumn le$el

Snta1: s%nta9 !"r c"lumn le$el c"nstraints using check

S7BV&R/T/ U+1TH)/VU+1NM/V (&+#MN NM/ UDTTH)/V(SO/'

&+NSTRNT U&+NSTRNTS NM/VUTH)/ +G &+NSTRNTSV(&+NSTRTNS &RT/R' ,

&+#MN NM/2 UDTTH)/V (SO/''

Command:

S7V&R/T/ T1/ /M)<(/M)N+ N#M1/R(3',/NM/ .R&AR2(20',D/SN .R&AR2(;',

S N#M1/R(;'CO(STR&(T /M)<PSP&K &A/&K(SV;00 NDSU000',

D/)TN+ N#M1/R(2''

Ta$le ,e5el Check Con"traint:

+%ER: <<

722 =rite a 8uer% t" create &heck c"nstraints ith tale le$el

Snta1: S%nta9 !"r Tale le$el c"nstraints using &heck

S7BV&R/T/ U+1TH)/VU+1NM/V (&+#MN NM/ UDTTH)/V(SO/',

(&+#MN NM/2 UDTTH)/V (SO/',

&+NSTRNTU&+NSTRNTS NM/VUTH)/ +G &+NSTRNTSV (&+NSTRTNS&RT/R''

Command:

S7V&R/T/ T1/ /M)>(/M)N+ N#M1/R(3',/NM/ .R&AR2(20',D/SN .R&AR2(;',

S N#M1/R(;',D/)TN+ N#M1/R(2',CO(STR&(TS /M)>PSP&K &A/&K(SV;00 &()SU000''

Check Con"traint with &lter Command:

+%ER:<=

723 =rite a 8uer% t" create &heck c"nstraints ith tale le$el using alter c"mmand

8

Page 88: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 88/238

Snta1: S%nta9 !"r Tale le$el c"nstraints using &heck

S7BV&R/T/ U+1TH)/VU+1NM/V (&+#MN NM/ UDTTH)/V(SO/',

(&+#MN NM/2 UDTTH)/V (SO/',&+NSTRNTU&+NSTRNTS NM/VUTH)/ +G &+NSTRNTSV (&+NSTRTNS&RT/R''

Command:

S7V&R/T/ T1/ /M)?(/M)N+ N#M1/R,/NM/ .R&AR2(20',D/SN .R&AR2(;',

S N#M1/R(;''

S7VT/R T1/ /M)? DD CO(STR&(TS /M)?PSP&K CHEC8 (SV;00 ND SU000'

%(+%E CO(STR&(T

t is used t" ensure that in!"rmati"n in the c"lumn !"r each rec"rd is uni8ue, as ith teleph"ne "r dri$er

license numers t pre$ents the duplicati"n "! $alue ith r"s "! a speci!ied c"lumn in a set "! c"lumn c"lumn

de!ined ith the c"nstraint can all" null $alue

! uni8ue ke% c"nstraint is de!ined in m"re than "ne c"lumn ie, c"minati"n "! c"lumn cann"t e speci!ied

Ma9imum c"minati"n "! c"lumns that a c"mp"site uni8ue ke% can c"ntain is 6

Col#mn ,e5el Con"traint:

+%ER:<>

72: =rite a 8uer% t" create uni8ue c"nstraints ith c"lumn le$el

Snta1: s%nta9 !"r c"lumn le$el c"nstraints ith uni8ue

S7 BV &R/T/ U+1TH)/VU+1NM/V (U&+#MN NM/V UDTTH)/V (SO/' &+NSTRNT

UNM/ +G &+NSTRNTSVU&+NSTRNT TH)/V,

(&+#MN NM/2 UDTTH)/V (SO/''

Command:

S7V&R/T/ T1/ /M)0(/M)N+ N#M1/R(3',/NM/ .R&AR2(20',

D/SN .R&AR2 (;'CO(STR&(T /M)0PD/SNP#K #N7#/,

S N#M1/R (;'' Ta$le ,e5el Con"traint:

+%ER: <?

72; =rite a 8uer% t" create uni8ue c"nstraints ith tale le$el

Snta1: s%nta9 !"r tale le$el c"nstraints ith uni8ue

S7 BV &R/T/ U+1TH)/VU+1NM/V (U&+#MN NM/VUDTTH)/V (SO/',

(&+#MN NM/2 UDTTH)/V (SO/',

&+NSTRNTUNM/ +G &+NSTRNTSVU&+NSTRNT TH)/V(&+#MN NM/''

Command:

S7V&R/T/ T1/ /M)(/M)N+ N#M1/R(3',/NM/ .R&AR2(20',D/SN .R&AR2(;',

S N#M1/R(;',

&+NSTRNT /M)PD/SNP#K #N#/(D/SN''

Ta$le ,e5el Con"traint &lter Command:

+%ER:<@

726 =rite a 8uer% t" create uni8ue c"nstraints ith tale le$el

Snta1: s%nta9 !"r tale le$el c"nstraints ith check using alter

S7 BV &R/T/ U+1TH)/VU+1NM/V (U&+#MN NM/VUDTTH)/V (SO/',

  (U&+#MN NM/2VUDTTH)/V (SO/''

8

Page 89: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 89/238

S7V T/R T1/ DD U&+NSTRNTSVU&+NSTRNTS NM/VU&+NSTRNTS TH)/V (&+#MN

 NM/'

Command:

S7V&R/T/ T1/ /M)2(/M)N+ N#M1/R(3',/NM/ .R&AR2(20',D/SN .R&AR2(;',

S N#M1/R(;''

S7VT/R T1/ /M)2 DD &+NSTRNT /M)2PD/SNP#K#N7#/(D/SN'

(OT (%,, CO(STR&(TS

=hile creating tales, % de!ault the r"s can ha$e null $alue the en!"rcement "! n"t null c"nstraint in a tal

ensure that the tale c"ntains $alues

Col#mn ,e5el Con"traint:

+%ER: <A

72< =rite a 8uer% t" create N"t Null c"nstraints ith c"lumn le$el

Snta1: s%nta9 !"r c"lumn le$el c"nstraints ith n"t null

S7 BV &R/T/ U+1TH)/VU+1NM/V(U&+#MN NM/VUDTTH)/V (SO/' &+NSTRNT

UNM/ +G &+NSTRNTSV U&+NSTRNT TH)/V,

(&+#MN NM/2 UDTTH)/V (SO/''

Command:

S7V&R/T/ T1/ /M)3(/M)N+ N#M1/R(:',

/NM/ .R&AR2(20' &+NSTRNT /M)3P/NM/PNN N+T N#,

D/SN .R&AR2(20',S N#M1/R(3''

(%,, CO(STR&(TS

Setting null $alue is appr"priate hen the actual $alue is unkn"n, "r hen a $alue "uld n"t e meaning!ul

• null $alue is n"t e8ui$alent t" a $alue "! Fer"

• null $alue ill ala%s e$aluate t" null in an% e9pressi"n

• =hen a c"lumn name is de!ined as n"t null, that c"lumn ec"mes a mandat"r%

ie, the user has t" enter data int" it

•  N"t null ntegrit% c"nstraint cann"t e de!ined using the alter tale c"mmand hen the tale c"ntain r"s

Col#mn ,e5el Con"traint:

+%ER:<

72> =rite a 8uer% t" create Null c"nstraints ith c"lumn le$el

Snta1: s%nta9 !"r c"lumn le$el c"nstraints ith null

S7 BV &R/T/ U+1TH)/VU+1NM/V (

U&+#MN NM/VUDTTH)/V (SO/' CO(STR&(T UNM/ +G &+NSTRNTSV U&+NSTRNT

TH)/V,(&+#MN NM/2 UDTTH)/V (SO/''

8

Page 90: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 90/238

Command:

S7V&R/T/ T1/ /M)3(/M)N+ N#M1/R(:',

/NM/ .R&AR2(20' &+NSTRNT /M)3P/NM/PNN N#,

D/SN .R&AR2(20',S N#M1/R(3''

)EF&%,T CO(STR&(TS

De!ault c"nstraints assign the de!ault $alues i! the $alues is n"t passed at the time "! inserting the $alues t" the tale

+%ER:<

72> =rite a 8uer% t" create de!ault c"nstraints ith c"lumn le$el

Snta1: s%nta9 !"r c"lumn le$el c"nstraints ith de!ault

S7 BV &R/T/ U+1TH)/VU+1NM/V (

U&+#MN NM/VUDTTH)/V (SO/' ,

U&+#MN NM/2 UDTTH)/V (SO/' )efa#lt Udefa#lt 5al#eV'

Command:

S7V &R/T/ T1/ DG(

R/N+ N#M1/R(;',

 NM/ .R&AR2(20',

MRKS N#M1/R(3' )EF&%,T ??

'

Tale created

S7V NS/RT NT+ DG .#/S(00,IR#NI,N#'

r" created

S7V NS/RT NT+ DG(R/N+' .#/S(DD?'

r" created

S7V NS/RT NT+ DG .#/S(00,IRI,<>'

r" created

S7V S//&T Q GR+M DG

R/N+ NM/ MRKS

----------- ---------- ------------

00 R#N

00; ;;

Page 91: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 91/238

00 R <>

)S&B,(6 &() )ROPP(6 CO(STR&(TS

%S(6 )S&B,E4E(&B,E

=hene$er a c"nstraint is created !"r a c"lumn(s', e$er% time an entr% is made t" the c"lumn , it must

e$aluated t" determine hether the $alue is all"ed in that c"lumn(it checks d"esnLt .i"late the c"nstraint' !

large l"ck "! data is eing added t" a tale the $alidati"n pr"cess can se$erel% sl" d"n the "racle ser$er

 pr"cessing speed H"u are certain that the data eing added t" a tale adheres t" the c"nstraints then disale th

c"nstraints hile adding that particular l"ck "! data "! data t" the tale

T" DS1/ a c"nstraint, issue an T/R T1/ c"mmand and change the status "! the c"nstraint t

DS1/ t a later time can reissue the T/R T1/ c"mmand and change the status "! the c"nstraint ack t

/N1/ S"metimes, temp"raril% disale "r dr"p a c"nstraint

Con"traint )i"a$le

+%ER:<

72? =rite a 8uer% t" disale the c"nstraints

Snta1: S%nta9 !"r disaling a single c"nstraint in a tale

S7VT/R T1/ UT1/-NM/V DS1/ &+NSTRNT U&+NSTRNTNM/V

S7VT/R T1/ /M)3 DS1/ &+NSTRNT /M)3P/NM/PNNN#

Con"traint Ena$le

+%ER: =D

730 =rite a 8uer% t" enale the c"nstraints

Snta1: Snta1 for di"a$lin- a "in-le con"traint in a ta$le:

S7VT/R T1/ UT1/-NM/V DS1/ &+NSTRNT U&+NSTRNTNM/V

Command:

S7VT/R T1/ /M)3 /N1/ &+NSTRNT /M)3P/NM/PNN N#

TO ,ST &,, THE CO(STR&(TS:

S7VS//&T Q GR+M #S/RP&+NSTRNTS

S7V S//&T &+NSTRNTPNM/,&+NSTRNTPTH)/,STT#S GR+M #S/RP&+NSTRNTS

&+NSTRNTPNM/ & STT#S

------------------------------ - --------SHSP&006;2 ) /N1/D

SHSP&006;; # /N1/D

SHSP&006;> ) DS1/D

: r"s selected

S7Vselect c"nstraintPname,c"nstraintPt%pe,status GR+M #S/RP&+NSTRNTS =A/R/ T1/PNM/1&

RES%,T:

Page 92: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 92/238

Thus the S7 c"mmands !"r &reating an /mpl"%ee dataase t" set $ari"us c"nstraints has een

$eri!ied and e9ecuted success!ull%

CRE&T(6 RE,&TO(SHP BET9EE( THE )&T&B&SES ( R)BMS

E1: (o: D? /?.0 TO MP,EME(T&TO( OF SET OPER&TORS

  : :  

&M:

T" /9ecute and $eri!% The S7 &"mmands G"r Set +perat"rs mplementati"n n Relati"nal M"del

OBJECT!E:

Set "perat"rs are used t" retrie$e the data !r"m t" "r multiple tales

The% are di!!erent t%pes

• #ni"n• #ni"n all

• ntersect

• Minus

&,6ORTHM:

STEP : Start

STEP <: &reate t" di!!erent tales ith its essential attriutes

STEP =: nsert attriute $alues int" the tales

STEP >: &reate the result !"r the $ari"us set "perati"n

STEP ?: /9ecute &"mmand and e9tract in!"rmati"n !r"m the tales

STEP @B St"p

S&MP,E T&B,ES

S7V select Q !r"m ST#D/NTPT

R/PN+ NM/ 1RN& S#1/&T

------------ --------------- ----------- --------000 ram T DT STR#&T#R/

0002 Sam T DT1S/ SHST/M

0003 Tam T =/1 T/&AN++H

000: R T DS)000; T T D)

0006 khan T =/1 T/&AN++H

3000; R /&/ &R&#T D/SN

< r"s selected

S7V select Q !r"m ST#D/NTP/&/

R/PN+ NM/ 1RN& S#1/&T

------------ ---------------- ---- ----- --------------------

3000 RM# /&/ D)30002 SM# /&/ DS)

30003 TM# /&/ &R&#T D/SN

Page 93: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 93/238

3000: R# /&/ //&TR+ M/&AN&S

3000; R /&/ &R&#T D/SN

3000; R /&/ &R&#T D/SN

%(O(

This ill c"mine the rec"rds "! multiple tales ha$ing the same structure

E1:

S7V select Q !r"m studentPT uni"n select Q !r"m studentP/&/

R/PN+ NM/ 1RN& S#1/&T

----------- -------- ----------- ------------------000 ram T DT STR#&T#R/

0002 Sam T DT1S/ SHST/M

0003 Tam T =/1 T/&AN++H

000: R T DS)

000; T T D)

0006 khan T =/1 T/&AN++H

3000 RM# /&/ D)

30002 SM# /&/ DS)

30003 TM# /&/ &R&#T D/SN

3000: R# /&/ //&TR+ M/&AN&S

3000; R /&/ &R&#T D/SN

r"s selected

%(O( &,,

This ill c"mine the rec"rds "! multiple tales ha$ing the same structure ut including duplicates

E1:

S7V select Q !r"m studentPT uni"n all select Q !r"m studentP/&/

R/PN+ NM/ 1RN& S#1/&T

------------- ----------- ----------- --------------------

000 ram T DT STR#&T#R/

0002 Sam T DT1S/ SHST/M

0003 Tam T =/1 T/&AN++H

000: R T DS)

000; T T D)

0006 khan T =/1 T/&AN++H

3000; R /&/ &R&#T D/SN

3000 RM# /&/ D)

30002 SM# /&/ DS)

30003 TM# /&/ &R&#T D/SN

3000: R# /&/ //&TR+ M/&AN&S

3000; R /&/ &R&#T D/SN3000; R /&/ &R&#T D/SN

3 r"s selected

(TERSECT

This ill gi$e the c"mm"n rec"rds "! multiple tales ha$ing the same structure

E1:

S7V select Q !r"m studentPT NT/RS/&T select Q !r"m studentP/&/

R/PN+ NM/ 1RN& S#1/&T

------------ --------- ----------- -----------------

Page 94: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 94/238

3000; R /&/ &R&#T D/SN

M(%S

This ill gi$e the rec"rds "! a tale h"se rec"rds are n"t in "ther tales ha$ing the same structure

E1:

S7V select Q !r"m studentPT MN#S select Q !r"m studentP/&/

R/PN+ NM/ 1RN& S#1/&T

------------ ---------- ---------- -------------------

000 ram T DT STR#&T#R/

0002 Sam T DT1S/ SHST/M

0003 Tam T =/1 T/&AN++H

000: R T DS)

000; T T D)

0006 khan T =/1 T/&AN++H

6 r"s selected

RES%,T:

Thus the S7 c"mmands !"r  S/T "perat"rs has een $eri!ied and e9ecuted success!ull%

Page 95: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 95/238

CRE&T(6 RE,&TO(SHP BET9EE( THE )&T&B&SES ( R)BMS

E1: (o: D? /?.<0 To im2lementation of (e"ted +#erie"

  : :  

&M:

T" e9ecute and $eri!% the S7 c"mmands !"r Nested 7ueries

OBJECT!E:

 Nested 7uer% can ha$e m"re than "ne le$el "! nesting in "ne single 8uer% S7 nested 8uer% is a

S//&T 8uer% that is nested inside a S//&T, #)DT/, NS/RT, "r D//T/ S7 8uer%

&,6ORTHM:

STEP : Start the pr"gram

STEP <: &reate t" di!!erent tales ith its essential attriutes

STEP =: nsert attriute $alues int" the tale

STEP >: &reate the Nested 8uer% !r"m the a"$e created tale

STEP ?: /9ecute &"mmand and e9tract in!"rmati"n !r"m the tales

STEP @: St"p the pr"gram

Table -

Page 96: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 96/238

Snta1: s%nta9 !"r creating a tale.

S7B &R/T/ U+1TH)/V U+1NM/V (&+#MN NM/ UDTTH)/V (SO/',

&+#MN NM/ UDTTH)/V (SO/' X'

Command:

S7V &R/T/ T1/ /M)2(/M)N+ N#M1/R(;',/NM/ .R&AR2(20',+1 .R&AR2(20',

S N#M1/R(6',MRN+ N#M1/R(:',D/)TN+ N#M1/R(3''

Snta1: s%nta9 !"r insert rec"rds in t" a taleS7 BV NS/RT NT+ UT1/ NM/V .#/SU ., L.2,X'

Command:

S7V S//&T QGR+M /M)2

/M)N+ /NM/ +1 S MRN+ D)TN+

----------- ---------- ------- ------------ ---------- ----------

00 MA/SA )R+RMM/R ;000 ;60 200

002 MN+ T/ST/R 2000 ;60 200003 KRTAK )R+RMM/R 3000 :00 20

00: NR/SA &/RK :00 :00 20

00; MN T/ST/R 3000 :00 200006 .K D/SN/R 2;00 ;60 2000< M+AN D/SN/R :000 ;60 20

00> N.//N &R/T+N 20000 :00 20

00? )RSD DR 20000 ;60 202

00 N/SA DR ;000 :00 200

T&B,E3 <

Snta1: s%nta9 !"r creating a tale

S7B &R/T/ U+1TH)/V U+1NM/V (&+#MN NM/ UDTTH)/V (SO/',

&+#MN NM/ UDTTH)/V (SO/' XXXXXX

Command:

S7V &R/T/ T1/ D/)T2(D/)TN+ N#M1/R(3',D/)TNM/ .R&AR2(0',

+&T+N .R&AR2(;''

Tale created

Snta1: s%nta9 !"r insert rec"rds in t" a tale

S7 BV NS/RT NT+ UT1/ NM/V .#/SU ., L.2,X'

S7V S//&T QGR+M D/)T2

D/)TN+ D/)TNM/ +&T+N

---------- ---------- ---------------0< D/./+) DHR 

20 D/1# #K  

200 T/ST #S20 T/ST #SSR 

0> D/1# DHR 

0? 1#D )+TA/R

6 r"s selected

Snta1:

6E(ER&, S(T&7 FOR (ESTE) +%ER:

Page 97: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 97/238

Page 98: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 98/238

E1: (o: D? /?.=0 To im2lementation the Join O2eration"

  : :  

&M:

T" e9ecute and $eri!% the S7 c"mmands !"r $ari"us @"in "perati"n

&,6ORTHM:

STEP : Start the pr"gram

STEP <: &reate t" di!!erent tales ith its essential attriutes

STEP =: nsert attriute $alues int" the tale

STEP >: &reate the tale "@ect !"r eas% re!erence

STEP ?: "in t" tales % using +N "perat"r

STEP @: Displa% the result "! the result tale

STEP A: St"p the pr"gram

JO(SB

 "ins are used t" retrie$e the data !r"m multiple tales

T2e" of Join"B

/7#P+N

2 N+N /7#P+N

3 S/G +N

: +#T/R +N

: Right "uter @"in

:2 e!t "uter @"in

:3 Gull "uter @"in

 E+%JO(B

=hen tales are @"ined asing "n a c"mm"n c"lumn it is called /7#P+N

Page 99: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 99/238

E1B

select empn", ename, dname !r"m emp, dept here empdeptn" deptdeptn"

EMPNO ENAME DNAME736 SIT@ +S&+-@74 &LL0 S&LS752; :&+ S&LS

(oteB

=e need t" menti"n @"in c"nditi"ns in the here clause

n /7#P+NS e al"ng use t" e8ual t" "perat"r in @"in c"nditi"n

E1B

SQL6S$#$t$ $04no2 $n!0$2 s!#2 7o"2 8n!0$2 #oc

9%o0 $042 8$4t

/&$%$ $048$4tno ; 8$4t8$4tno5

SQL6Selete empn", ename, sal, deptn", dname, l"c

!r"m emp, dept

here empdeptn" deptdeptn"44 err"r

SQL6Selete empn", ename, sal, empdeptn", dname, l"c

!r"m emp, dept

here empdeptn" deptdeptn" 44$alid

(oteB

• e need t" menti"n tale name d"t c"lumn(empdeptn"' name !"r the c"mm"n c"lumn t" res"l$e th

an% tale

• The c"mm"n c"lumn can e retrie$ed !r"m an% "! the tale

• =e can !ilter the data !r"m the result "! @"in

E1B

SQL6Select empn", ename, sal, empdeptn", dname, l"c

!r"m emp, dept

Page 100: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 100/238

here empdeptn" deptdeptn" ND sal V 2000

T" impr"$e the per!"rmance "! the @"in e need menti"n tale name d"t c"lumn name !"r all the c"lumns

E1B

SQL6Select empempn", empename, empsal,empdeptn", deptdname, deptl"c

!r"m emp,dept

here empdeptn" deptdeptn" ND sal V 2000

Ta$le alia"B

• Tale alias is an alternate name gi$en t" a tale

• 1% using a tale alias length "! the tale reduces and at the same time per!"rmance is maintains

• Tale alias are create in same clause can e used in select clause as ell as here clause

Tale alias is temp"rar% "nce the 8uer% is e9ecuted the tale alias are l"sed

E1B

SQL6Select //mpn", //name, /sal, /deptn", DDname, Dl"c

!r"m emp /, Dept D

here /deptn" Ddeptn"

Join the m#lti2le ta$le"/= ta$le"0B

Select Q !r"m reas

Cit State

 Ne%"rk )

Dallas Mh

E1B

SQL6Select /empn", /ename, /sal,Ddname,state

!r"m emp /, dept D, reas

here /deptn" Ddeptn" ND Dl"c cit%

(oteB T" @"in Ln tales e need n- c"nditi"ns

(O( E+% JO(B

=hen e d" n"t use N+N /7# +N t" "perat"r in the @"in c"nditi"n is N+N /7# +N

E1B

;<

Page 101: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 101/238

SQL6Select Q !r"m SRD/

RD/ +S AS <00 200

2 20 :00

3 :0 2000

: 200 3000; 300 ????

SQL6Select eempn", eename, esal, sgrade

!r"m emp e, salgrade s

here esal 1/T=//N sl"sal ND hisal

/M)N+ /NM/ RD/

<36? SMTA <><6 DMS

<?00 M/S 2

SQL6Select eempn", eename, sgrade

!r"m emp e, salgrade s

here esal 1/T=//N sl"sal ND shisal ND sgrade :

SE,F JO(B

=hen a tale is @"ining t" it sel! it is called sel! @"in n sel! @"ins e need t" create t" tale aliases

!"r the same tale

SQL6Select empn", ename, @", mgr, !r"m emp

SQL6Select eempn", eename, e@", mename

!r"m emp e, emp m

here emgr mempn"

Em2no Ename Jo$ Ename

<?02 G+RD NHST +N/S

<>6? S&+TT &/RK +N/S

<?00 M/S S/SMN 1K/

C&RTES&( PRO)%CTB

=hen tales are @"ined ith"ut an% @"in c"nditi"n it is called &artesian pr"duct n the result e get

all p"ssile c"minati"n

SQL6Select eempn", eename, esal, edeptn", ddname, dl"c

;<

Page 102: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 102/238

!r"m emp e, dept d 44:Q:;6 r"s are selected

&(S JO(SB

The% are the three t%pes

((ER JO(SB

t is same as /8ui @"in

E1B

SQL6Select eempn", eename, esal, edeptn", ddname, dl"c

!r"m emp e NN/R +N dept d +N(edeptn" ddeptn"'

2(&T%R&, JO(B

t is same as /8ui @"in

E1B

SQL6Select empn", ename, sal, deptn", dname,l"c !r"m NT#R +N dept

CROSS PRO)%CT4CROSS JO(B

t is same as &artesian pr"duct

E1B

SQL6Select eempn", eename, esal, edeptn", ddname, dl"c

!r"m emp e &R+SS +N dept d 44:Q: ;6 r"s are displa%ed

)EF&%,TB

E1B

SQL6&reate tale stu(sn" numer(3',

Sname $archar2(0',

Marks numer(3' de!ault 00,

D"@ Date D/G#T s%sdate'

 

SQL6nsert int" stu(sn", sname' $alues(0,malli'

SQL6nsert int" stu $alues(02,R#N,:0,-N-0?'

SQL6nsert int" stu $alues (03,KRN,N#,2-G/1-0'

SN+ SNM/ MRKS D+

;<

Page 103: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 103/238

0 malli 00 26-#N-2

02 R#N :0 -N-0?

03 KRN 2-G/1-0

S%PER 8EB

&"minati"n "! c"lumns hich can e used uni8ue ke% identi!% e$er% r" is called as super ke%

Tale "@ect

&"lumn ttriutes

R" Tuple4Rec"rd

O%TER JO(SB

t is e9tensi"n "! /7# +NS

n "uter @"ins e get match as ell as n"n matching r"s

(C' This called as "uter @"in "perat"r

. R6HT O%TER JO(B

S+, Snta1B

SQL6Select eempn", eename, esal, edeptn", ddname, dl"c

!r"m emp e, dept d

here edeptn"(C' ddeptn" 44: C ; r"s

em2no ename "al de2tno dname loc

<?00 @ames ?;0 30 sales chicag"

>?63 adams :00 20 clerk ne%"rk

6<?> adams 2000 0 sales india

&(S S(T&7 OF R6HT O%TER JO(B

NS SHSTEB

SQL6Select eempn", eename, esal, edeptn", ddname, dl"c

!r"m emp e RAT +#T/R +N dept d +N(edeptn" ddeptn"'

,EFT O%TER JO(B

S+, Snta1B

SQL6Select eempn", eename, esal, edeptn", ddname, dl"c

!r"m emp e, dept d

;<

Page 104: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 104/238

here edeptn" ddeptn"(C' 44:C3 < r" displa%ed

&(S S(T&7 OF ,EFT O%TER JO(B

&(S S(T&7:

SQL6Select eempn", eename, esal, edeptn", ddname, dl"c

!r"m emp e /GT +#T/R +N dept d +N(edeptn" ddeptn"'

F%,, O%TER JO(B

&(S S(T&7B

SQL6Select eempn", eename, esal, edeptn", ddname, dl"c

!r"m emp e G# +#T/R +N dept d +N(edeptn" ddeptn"'

44: C 2 C 3 ? r"s are displa%ed

RES%,T:

Thus the S7 c"mmands to implementati"n the @"in "perati"ns has een $eri!ied and e9ecuted

success!ull%

St#d of P,4S+, $lock.

E1: (o: D@

  : :  

;<

Page 105: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 105/238

Page 106: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 106/238

1/N

  /9ecutale c"mmands --------- (MNDT+RH'

/E&/)T+N

  /9cepti"n handlers ----------(+)T+N'

/ND

4     T" e9ecute the pr"gram 4 c"mmand

)eclare:

This secti"n is used t" declare l"cal $ariales, curs"rs, /9cepti"ns and etc This secti"n is "pti"nal

E1ec#ta$le Section:

This secti"n c"ntains lines "! c"de hich is used t" c"mplete tale t is mandat"r%

E1ce2tion Section:

This secti"n c"ntains lines "! c"de hich ill e e9ecuted "nl% hen e9cepti"n is raised This

secti"n is "pti"nal

Sim2le"t P,4S+, Block:

1egin

--------

--------

--------

/ND

SER!ERO%TP%T

This ill e used t" displa% the "utput "! the )4S7 pr"grams 1% de!ault this ill e "!!

Snta1:

Set ser$er"utput "n ^ "!! 

E1:

S7V set ser$er"utput "n

B,OC8 TPES

• n"n%m"us l"cks

•  Named l"cks

aeled l"cks

Supr"grams

;<

Page 107: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 107/238

Triggers

&(O(MO%S B,OC8S

n"n%m"us l"cks implies asic l"ck structure

E1:

7 B pr"gram t" displa% the string J

1/N

D1MSP+#T)#T)#TPN/(LM fir"t 2ro-ram*'B

/ND

4

,&BE,E) B,OC8S

aeled l"cks are an"n%m"us l"cks ith a lael hich gi$es a name t" the l"ck

E1:

UUm%Pl""ckVV

1/N

DmsP"utputputPline(LM% !irst pr"gram'B/ND

S%BPRO6R&MS

Supr"grams are pr"cedures and !uncti"ns The% can e st"red in the dataase as stand-al"n

"@ects, as part "! package "r as meth"ds "! an "@ect t%pe

TR66ERS

Triggers c"nsist "! a )4S7 l"ck that is ass"ciated ith an e$ent that "ccurs in the dataase

(ESTE) B,OC8S

l"ck can e nested ithin the e9ecutale "r e9cepti"n secti"n "! an "uter l"ck

)E(TFERS

• denti!iers are used t" name )4S7 "@ects, such as $ariales, curs"rs, t%pes and supr"grams

• denti!iers c"nsists "! a letter, "pti"nall% !"ll"ed % an% se8uence "! characters, including letters,

numers, d"llar signs, undersc"res, and p"und signs "nl% The ma9imum length !"r an identi!ier is30 characters

+%OTE) )E(TFERS

! %"u ant t" make an identi!ier case sensiti$e, include characters such as spaces "r use a reser$ed

"rd, %"u can encl"se the identi!ier in d"ule 8u"tati"n marks

E1:

D/&R/

;<

Page 108: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 108/238

a numer B ;

numer B 6

1/N

dmsP"utputputPline(Qa V Q ^^ a'

dmsP"utputputPline(Q& V Q ^^ '

/ND

4

O#t2#t:

a 6

6

COMME(TS

&"mments impr"$e readailit% and make %"ur pr"gram m"re understandale The% are ign"red %

the )4S7 c"mpiler

There are t" t%pes "! c"mments a$ailale

• Single line c"mments

;<

Page 109: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 109/238

• Multiline c"mments

S(6,E ,(E COMME(TS

single-line c"mment can start an% p"int "n a line ith t" dashes and c"ntinues until the end

"! the line

E1:

1/N

DmsP"utputputPline(Lhell"'  33 "am2le 2ro-ram

/ND

4

M%,T,(E COMME(TS

Multiline c"mments start ith the 4Q delimiter and ends ith Q4 delimiter

E1:

1/N

DmsP"utputputPline(Lhell"' 4 "am2le 2ro-ram 4

/ND

4

!&R&B,E )EC,ER&TO(S

.ariales can e declared in declarati$e secti"n "! the l"ck

E1:

D/&R/

a n#m$erI

$ n#m$er :V ?I

c n#m$er defa#lt @I

CO(ST&(T )EC,ER&TO(S

T" declare a c"nstant, %"u include the &+NSTNT ke%"rd, and %"u must suppl% a de!ault $alue

E1:

D/&R/

  con"tant numer B ;

;<

Page 110: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 110/238

c con"tant numer de!ault 6

(OT (%,, C,&%SE

H"u can als" speci!% that the $ariale must e n"t null

E1:

D/&R/

  c"nstant numer not n#llB ;

c numer n"t null defa#lt @

&(CHORE) )EC,ER&TO(S

)4S7 "!!ers t" kinds "! anch"ring

• Scalar anch"ring

• Rec"rd anch"ring

SC&,&R &(CHOR(6

#se the _TH)/ attriute t" de!ine %"ur $ariale ased "n tales c"lumn "! s"me "ther )4S7

scalar $ariale

E1:

D/&R/

dn" de2t.de2tnot2eI

Sut%pe tPnumer is numer

a tPnumer

Sut%pe tPsn" is "t#dent."not2eI

.Psn" tPsn"

RECOR) &(CHOR(6

#se the _R+=TH)/ attriute t" de!ine %"ur rec"rd structure ased "n a tale

E1:

D/&R/

.Pdept de2trowt2eI

;;

Page 111: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 111/238

Benefit" of &nchored )eclaration"

• S%nchr"niFati"n ith dataase c"lumns

•  N"rmaliFati"n "! l"cal $ariales

PRO6R&MMER3)EF(E) TPES

=ith the S#1TH)/ statement, )4S7 all"s %"u t" de!ine %"ur "n sut%pes "r aliases "! prede!ined datat%pes, s"metimes re!erred t" as astract datat%pes

There are t" kinds "! sut%pes

• &"nstrained

• #nc"nstrained

CO(STR&(E) S%BTPE

sut%pe that restricts "r c"nstrains the $alues n"rmall% all"d % the datat%pe itsel!

E1:

Sut%pe p"siti$e is inar%Pinteger range 2:<:>36:<

• n the a"$e declarati"n a $ariale that is declared as p"siti$e can st"re "nl% ingeger greater 

than Fer" e$en th"ugh inar%Pinteger ranges !r"m -2:<:>36:<C2:<:>36:<

%(CO(STR&(E) S%BTPE

sut%pe that d"es n"t restrict the $alues "! the "riginal datat%pe in $ariales declared ith thesut%pe

E1:

Sut%pe !l"at is numer

)&T&TPE CO(!ERSO(S

)4S7 can handle c"n$ersi"ns eteen di!!erent !amilies am"ng the datat%pes

&"n$ersi"n can e d"ne in t" a%s

/9plicit c"n$ersi"n

mplicit c"n$ersi"n

;;

Page 112: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 112/238

E7P,CT CO(!ERSO(

This can e d"ne using the uilt-in !uncti"ns a$ailale

MP,CT CO(!ERSO(

)4S7 ill aut"maticall% c"n$ert eteen datat%pe !amilies hen p"ssile

E1:

D/&R/

a $archar(0'

1/N

select deptn" int" a !r"m dept here dnameI&&+#NTNI

/ND

n the a"$e $ariale a is char t%pe and deptn" is numer t%pe e$en th"ugh, "racle ill aut"maticall

c"n$erts the numeric data int" char t%pe assigns t" the $ariale

)4S7 can aut"maticall% c"n$ert eteen

• &haracters and numers

• &haracters and dates

!&R&B,E SCOPE &() !SB,T

The sc"pe "! a $ariale is the p"rti"n "! the pr"gram in hich the $ariale can e accessed G"r

)4S7 $ariales, this is !r"m the $ariale declarati"n until the end "! the l"ck =hen a $ariale g"es "ut

"! sc"pe, the )4S7 engine ill !ree the mem"r% used t" st"re the $ariale

The $isiilit% "! a $ariale is the p"rti"n "! the pr"gram here the $ariale can e accessed ith"ut

ha$ing t" 8uali!% the re!erence The $isiilit% is ala%s ithin the sc"pe ! it is "ut "! sc"pe, it is n"t $isil

;;

Page 113: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 113/238

E1:

D/&R/

a numer 33 "co2e of a

1/N

--------

D/&R/  numer 33 "co2e of $

1/N

-----/ND

------

/ND

E1<:

D/&R/

a numer

  numer1/N

33 a ' $ a5aila$le here

D/&R/

  char(0'1/N

33 a and char t2e $ i" a5aila$le here

/ND-----

/ND

E1=:

UUm%Pl"ckVV

D/&R/

a numer  numer

1/N33 a ' $ a5aila$le here

D/&R/

  char(0'

1/N

33 a and char t2e $ i" a5aila$le here

33 n#m$er t2e $ i" a5aila$le #"in- m$lockLL.$

/ND

------/ND

P,4S+, CO(TRO, STR%CT%RES

)4S7 has a $ariet% "! c"ntr"l structures that all" %"u t" c"ntr"l the eha$i"ur "! the l"ck a

it runs These structures include c"nditi"nal statements and l""ps

• !-then-else

• &ase

o &ase ith n" else

o aeled case

o Searched case

;;

Page 114: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 114/238

Page 115: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 115/238

=hen valuen then sequence of statements;

/lse sequence of statements;

/nd case

E1:

D/&R/

dno numer(2'

1/N

select deptn" int" dno !r"m dept here dname I&&+#NTNI

case dno

hen D then

dmsP"utputputPline(I"cati"n is N/= H+RKI'

hen <D then

dmsP"utputputPline(I"cati"n is DSI'

hen =D then

dmsP"utputputPline(I"cati"n is &A&+I'

el"e

dmsP"utputputPline(I"cati"n is 1+ST+NI'

end case

/ND

O#t2#t:

"cati"n is N/= H+RK 

C&SE 9THO%T E,SE

Snta1:

&ase test-variable

=hen value-1 then sequence of statements;

=hen value-2 then sequence of statements;

XX

=hen value-n then sequence of statements;

;;

Page 116: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 116/238

/nd case

E1:

D/&R/

dn" numer(2'

1/N

select de2tno int" dno !r"m dept here dname I&&+#NTNI

case dno

hen D then

dmsP"utputputPline(I"cati"n is N/= H+RKI'

hen <D then

dmsP"utputputPline(I"cati"n is DSI'

hen =D then

dmsP"utputputPline(I"cati"n is &A&+I'

hen >D then

dmsP"utputputPline(I"cati"n is 1+ST+NI'

end case

/ND

O#t2#t:

"cati"n is N/= H+RK 

,&BE,E) C&SE

Snta1:

UUlaelVV

&ase test-$ariale

=hen $alue then se8uence "! statements

=hen $alue2 then se8uence "! statements

XX

=hen $aluen then se8uence "! statements

;;

Page 117: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 117/238

/nd case

E1:

D/&R/

dn" numer(2'

1/N

select deptn" int" dn" !r"m dept here dname I&&+#NTNI

UUm%PcaseVV

case dn"

hen 0 then

dmsP"utputputPline(I"cati"n is N/= H+RKI'

hen 20 then

dmsP"utputputPline(I"cati"n is DSI'

hen 30 then

dmsP"utputputPline(I"cati"n is &A&+I'

hen :0 then

dmsP"utputputPline(I"cati"n is 1+ST+NI'

end case

mca"eI

/ND

O#t2#t:

"cati"n is N/= H+RK 

SE&RCHE) C&SE

Snta1:

&ase

=hen Ucondition-1V then sequence of statements;

=hen Ucondition-2V then sequence of statements;

XX

=hen Ucondition-nV then sequence of statements;

/nd case

;;

Page 118: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 118/238

Page 119: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 119/238

/nd i!

E1:

D/&R/

i numer B

1/N

loo2

dmsP"utputputPline(Ii I ^^ i'

i B i C

e9it hen i V ;

end loo2I

/ND

O#t2#t:

i

i 2

i 3

i :

i ;

9H,E ,OOP

Snta1:

=hile Uc"nditi"nV l""p

Sequence of statements;

/nd l""p

E1:

D/&R/

i numer B

1/N

9hile i U ; loo2

;;

Page 120: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 120/238

dmsP"utputputPline(Ii I ^^ i'

i B i C

end loo2I

/ND

O#t2#t:

i

i 2

i 3

i :

i ;

FOR ,OOP

Snta1:

G"r Uloop_counter_variableV in low_bound i!_bound l""p

Sequence of statements;

/nd l""p

E1:

1/N

For i in ; loo2

dmsP"utputputPline(Ii I ^^ i'

end loo2

/ND

;2

Page 121: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 121/238

O#t2#t:

i

i 2

i 3

i :

i ;

E1<:

1/N

G"r i in re$erse ; l""p

dmsP"utputputPline(Ii I ^^ i'

end l""p

/ND

O#t2#t:

i ;

i :

i 3i 2

i

6OTO &() ,&BE,S

Snta1:

"t" label 

=here label is a lael de!ined in the )4S7 l"ck aels are encl"sed in d"ule angle rackets

=hen a g"t" statement is e$aluated, c"ntr"l immediatel% passes t" the statement identi!ied %

the lael

E1:

1/N

For i in ; loo2

dmsP"utputputPline(Ii I ^^ i'

i! i : then

;2

Page 122: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 122/238

Page 123: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 123/238

RES%,T:

Thus the Stud% "! )4S7 l"ck has een implemented % $ari"us c"ntr"l structure are $eri!ied and

e9ecuted success!ull%

!r"te a #L/S$L bloc% to sat"s' some cond"t"ons b' acce(t"ng "n(ut rom the

user)

E1: (o: DA

  : :  

&M:

T" implement the )4S7 l"ck t" satis!% s"me c"nditi"ns % accepting input !r"m the user

&,6ORTHM:

STEP : Start the pr"gram

STEP <: &reate the tale ith its essential attriutes

;2

Page 124: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 124/238

Page 125: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 125/238

)4S7 pr"cedure success!ull% c"mpleted

+<: =rite a )4S7 l"ck hich accepts empl"%ee numer and increment is salar% % 000]

D/&R/ numer(:'

B 5/mpn"

#pdate emp set sal sal C 000 here /mpn" /ND

4

+=: =rite a )4S7 l"ck hich empn" and delete that r" !r"m the emp tale]

D/&R/

numer(:'

1/N B 5/mpn"

Delete !r"m emp here /mpn"

/ND

4

+>: )4S7 !"r re$ersing the gi$en string

&l-orithm:

et the input string

2 Gind the length "! the string

3 /9tract the characters "ne % "ne !r"m the end "! the string

: &"ncatenate the e9tracted characters

; Displa% the c"ncatenated re$ersed string

6 St"p the pr"gram

Pro-ram:

declare

  $archar2(0' B I5I

c $archar2(0'

l numer(2'

i numer(2'

g numer(2'

;2

Page 126: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 126/238

Page 127: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 127/238

a B 0 B

dmsP"utputputPline(I!i"nacci series isI'

dmsP"utputputPline(a'

dmsP"utputputPline('

!"r i in 3 n

l""p

c B a C

dmsP"utputputPline(c'a B

  B c

end l""p

e9cepti"n

hen negati$e then

dmsP"utputputPline(In sh"uld e greater than I'

end

S+,L 4

/nter $alue !"r nB0

"ld ;B n numer(3'B5n

ne ;Bn numer(3'B0

Gi"nacci

0

2

3

;>

3

2

3:

P,4S+, pr"cedure success!ull% c"mpleted

+@: )r"gram t" check hether gi$en numer is rmstr"ng "r n"t

&l-orithm:

Step B Declare the $ariale N, S, D and D#)Step 2B St"re the $alue in $ar N and $ar D#)

Step 3B check !"r the $alue "! N, hich is n"t e8ual t" 0

Step :B di$ide $alue st"red in N % 0 and st"re it $ar D (Dn_0'

Step ;B the reminder ill e multipl% 3 times and st"re it in .ar SStep 6B The c"e!!icient ill e calculated using G++R !uncti"n nd st"re it in $ar N

Step <B repeat the Steps 3, :, ;, and 6 till l""p ill e terminated

Step >B &heck hether the st"red $alue and calculated $alues are sameStep ?B i! "th the $alues are same, then displa% JThe gi$en numer is rmstr"ng

Step 0B +therise displa% Jit is n"t rmstr"ng and terminate the l""p

;2

Page 128: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 128/238

Declare

 N numerS numer

D numer

1egin NB5n

SB0

=hile(n0'""p

Dn_0

SBsC(DQDQD'

 NB!l""r(n40'/nd l""p

! (D#)S' then

D1MSP"utputputPline(Lnumer is armstr"ng'/lse

D1MSP"utputputPline(Lnumer is n"t armstr"ng'

/nd i!

/nd

Te"t !alid )ata Set:

/nter $alue "! n;3

O#t2#t:

numer is rmstr"ng

+A: =rite a pr"gram t" generate all prime numers el" 00

&MB t" generate all prime numers el" 00

Declare

numer

numer& numer

1egin

=hile(iU00'""p

&B0

B=hile(@Ui'

""p!(!l""r(i_@'0' then

&B &C/nd i!

B@C

/nd l""p!(c2' then

DmsP"utputputPline(i'

/nd i!/ndl""p

/nd

;2

Page 129: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 129/238

!alid Te"t )ata

O%TP%T:

2

3

;

<

??

+: =rite a pr"gram t" dem"nstrate _t%pe and _r"t%pe attriutes

&MB t" dem"nstrate _t%pe and _r"t%pe attriutes

Declare

M%P/mpn" empempn"_t%pe

M%P/name empename_t%pe

M%P/mpr" emp_r"t%pe

 N" numer

1egin

 N"B5n"

Select empn",ename int" m%Pempn",m%Pename !r"m emp here empn"n"

!(S7l_r"c"unt' then

DmsP"utputputPline(Lempn" is ̂ ^ m%Pempn" ^^ Lename is L ^^ m%Pename'

/lse

DmsP"utputputPline( Lerr"r'

/nd i!

Select Q int" m%Pempr" !r"m emp here empn"n"

!(S7l_r"c"unt' then

  DmsP"utputputPline(Lempn" is ̂ ^ m%Pempr"empn" ^^ Lename is L ^^ m%Pempr"ename'

/lse

DmsP"utputputPline( Lerr"r'

/nd i!

/nd

;2

Page 130: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 130/238

!alid Te"t )ata

/nter the $alue !"r n"B

<<>>

O%TP%T

empn" is <<>> ename is $ina% s

empn" is <<>> ename is $ina% s

RES%,T:

Thus the )4S7 l"ck t" satis!% s"me c"nditi"ns % accepting input !r"m the user  has een $eri!ied and

e9ecuted success!ull%

!r"te a #L/S$L bloc% that handles all t'(es o e*ce(t"ons .

E1: (o: D

  : :  

&M:

T" =rite a )4S7 l"ck that handles all t%pes "! e9cepti"ns

&,6ORTHM:

STEP: Start the pr"gram

STEP<: &reate a tale ith s"me $alid data

 STEP=: rite the )4S7 pr"gram that t" handle the e9cepti"n "n e9cepti"n l"ck 

STEP>: /9ecute the )4S7 pr"gram and gi$e the input $alues "r make the err"r "n the tale data

STEP?: Displa% the )4S7 pr"gram err"r message

STEP@: St"p the pr"gram

E7CEPTO(SB

;3

Page 131: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 131/238

n )4S7, err"rs and arnings are called as e9cepti"ns =hene$er a prede!ined err"r "ccurs in th

 pr"gram, )4S7 raises an e9cepti"n G"r e9ample, i! %"u tr% t" di$ide a numer % Fer" then )4S7

raises an e9cepti"n called O/R+PD.D/ and i! S//&T can n"t !ind a rec"rd then )4S7 raise

e9cepti"n N+PDTPG+#ND

)4S7 has a c"llecti"n "! prede!ined e9cepti"ns /ach e9cepti"n has a name These e9cepti"ns ar

aut"maticall% raised % )4S7 hene$er the c"rresp"nding err"r "ccurs

n additi"n t" )4S7 prede!ined e9cepti"ns, user can als" create his "n e9cepti"ns t" deal it

err"rs in the applicati"ns

The% are three t%pes "! /9cepti"ns

+R&/ )rede!ined /9cepti"n

2 +R&/ N"n )rede!ined /9cepti"n

3 #S/R De!ined /9cepti"n

S(T&7 OF E7CEPTO( H&(),(6

=A/N e9cepti"n- Y"r e9cepti"n -2Z TA/N

statements

Y=A/N e9cepti"n-3 Y"r e9cepti"n-:Z TA/N

statements Z

Y=A/N +TA/RS TA/N

statements Z

Q: The #$$1in% e9ampe handes NO<DATA<FOUND e9cep!i$n.

decare

C

be%in

seec! C

e9cep!i$n

1hen no<8!t!<9oun8 !hen

s!a!emen!sA

endA

O#t2#t:

;3

Page 132: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 132/238

Q: The #$$1in% e9cep!i$n handin% par! !aDes !he same ac!i$n 1hen ei!her

NO<DATA<FOUND $r

TOO<MANY<ROWS e9cep!i$ns $ccur.

decare...

be%in

seec! ...

e9cep!i$n

1hen n$da!a#$und o% !$$manyr$1s !hen

s!a!emen!sA

endA

O#t2#t:

Q: The #$$1in% snippe! handes !hese !1$ e9cep!i$ns in diEeren! 1ays.

decare

...

be%in

seec! ...

e9cep!i$n

1hen no<8!t!<9oun8 !hens!a!emen!sA

1hen too<0!n*<%o/s !hen

s!a!emen!sA

endA

O#t2#t:

WHEN OTHERS is used !$ e9ecu!e s!a!emen!s 1hen an e9cep!i$n $!her !han 1ha!are men!i$ned in e9cep!i$n hander has $ccurred.

decare

ne1cc$de ,archar2)5* FG nuA

be%in

upda!e c$urses se! cc$de G ne1cc$de 1here cc$de G HcHA

e9cep!i$n

1hen 8u4<.!#<on<in8$+ !hen

;3

Page 133: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 133/238

Page 134: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 134/238

This /9cepti"n is Raised i! a S//&T NT+ statement returns n" r"s "r i! %"u re!erence an un-

initialiFed r" in a )4S7 tale

E1B

Declare

Psal empsal_t%pe

1egin

D1MSP+#T)#T)#TPN/( L=/&+M/ '

Select sal NT+ Psal !r"m emp here empn" 5empn"

D1MSP+#T)#T)#TPN/(Psal'

D1MSP+#T)#T)#TPN/( LTANK H+# '

/E&/)T+N

hen (O)&T&FO%() then

D1MSP+#T)#T)#TPN/( LN.D /M)N+'

/ND

4

TOOM&(RO9SB

This /9cepti"n is Raised i! a S//&T NT+ statement returns m"re than "ne r"

E1B

Declare

Psal empsal_t%pe

1egin

D1MSP+#T)#T)#TPN/( L=/&+M/ '

Select sal NT+ Psal !r"m emp here deptn" 30

D1MSP+#T)#T)#TPN/(Psal'

D1MSP+#T)#T)#TPN/( LTANK H+# '

/E&/)T+N

hen T++PMNHPR+=S then

D1MSP+#T)#T)#TPN/( LM+R/ TA/N +N/ R+= R/T#RN/D'

/ND

4

WERO)!)EB

Raised hen %"ur pr"gram attempts t" di$ide a numer % Fer"

E1B

Declare

Numer

1egin

B ;40

/9cepti"n

;3

Page 135: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 135/238

hen O/R+PD.D/ then

D1MSP+#T)#T)#TPN/( LD+ N+T D.D/ 1H 0 '

/ND

4

(oteB

This /9cepti"n is raised hen e tr% t" di$ided % Fer"

!&,%EERROR B

This /9cepti"n is raised hen there is miss match ith the $alue and data t%pe "! l"cal $ariale "r

siFe "! l"cal $ariales

E1 B

Declare

Psal empsal_t%pe

1egin

D1MSP+#T)#T)#TPN/( L=/&+M/ '

Select ename NT+ Psal !r"m emp here empn" <;2

D1MSP+#T)#T)#TPN/(Psal'

D1MSP+#T)#T)#TPN/( LTANK H+# '

/E&/)T+Nhen .#/P/RR+R then

D1MSP+#T)#T)#TPN/( Lplease check the l"cal $ariales'

/ND

4

E1 2B

Declare

numer(3'1egin

B 23:/9cepti"n

hen .#/P/RR+R then

D1MSP+#T)#T)#TPN/( L)/S/ &A/&K TA/ +& .R1/S '

/ND4

)%P!&,O(()E7B (duplicate $alue "n inde9'

This /9cepti"n is raised hen e tr% t" insert a duplicate $alue in primar% ke% c"nstraint

;3

Page 136: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 136/238

E1B

1egin

D1MSP+#T)#T)#TPN/( Lelc"me '

nsert int" student $alues(0:, LR#N,60'D1MSP+#T)#T)#TPN/( LThank %"u '

/9cepti"n

hen D#)P.P+NPND/E thenD1MSP+#T)#T)#TPN/(L D" n"t insert duplicates '

/ND

4

The a"$e pr"gram "rks "n an assumpti"n the tale student !"r i! ha$ing a primar% ke% SN+ c"lumn ith

$alue 0:

9HE( OTHERSB

=hen "thers are a uni$ersal /9cepti"n angular this can catch all the /9cepti"ns

Declare

Psal numer(:'

numer

1egin

D1MSP+#T)#T)#TPN/( L=elc"me '

Select sal NT+ PS !r"m emp here deptn" 5deptn"

D1MSP+#T)#T)#TPN/(LThe sal is X^^Psal'

B040

D1MSP+#T)#T)#TPN/( LThank %"u '

/9cepti"n

=A/N +TA/RS TA/ND1MSP+#T)#T)#TPN/( Lplease check the c"de '

/ND

4

ERROR REPORT(6 F%(CTO(SB

The% are t" /rr"r Rep"rting !uncti"ns

S7&+D/

2 S7/RRM

These err"r rep"rting !uncti"ns are used in hen "thers clause t" identi!ied the e9cepti"n hich is raised S+,CO)EB t returns /RR+R&+D/

2 S+,ERRMB t returns /9cepti"n numer and /9cepti"n message

(oteB !"r N+PDTPG+#ND /9cepti"n S7&+D/ ill return 00

Declare

Psal numer(:'

numer

;3

Page 137: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 137/238

Page 138: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 138/238

Page 139: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 139/238

/ND

4

)ragma /9cepti"nPinit is a c"mpiler directi$e hich is used t" ass"ciated an /9cepti"n name t" the

 prede!ined numer

%SER )EF(E) E7CEPTO(B

These /9cepti"ns are de!ined and c"ntr"lled % the user These /9cepti"ns neither ha$e prede!ined

name n"r ha$e prede!ined numer Steps t" handle user de!ined /9cepti"ns

Ste2: )eclare the E1ce2tion

declareout_of_stock exception;

beginstatements;

end;

Ste2<: Rai"ed the E1ce2tion

if qty < 10 thenraise out_of_stock;

end if;

Ste2=: Catch the E1ce2tion

exceptionwhen out_of_stock then

-- handle the exception (that is reraised in outerblock

!!!end;

E1

Declare

MHP/E /E&/)T+N --Step

PS /M)S_TH)/

1egin

D1MSP+#T)#T)#TPN/(Lelc"me'

Select S NT+ PS !r"m emp here empn" 5empn"

G PS V 2000 TA/N

RS/ MHP/E --Step2

/NDG

D1MSP+#T)#T)#TPN/(LThe sal is X L^^Psal'

;3

Page 140: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 140/238

D1MSP+#T)#T)#TPN/(LThank %"u'

/E&/)T+N

=A/N MHP/E TA/N --Step3

D1MSP+#T)#T)#TPN/(LSal is t" high'

/ND

4

(oteB =hen "thers sh"uld e the last handler "! the e9cepti"n secti"n "ther ise e get a c"mpiler /RR+R

R&SE&PP,C&TO(ERROR:

• RS/P))&T+NP/RR+R is a pr"cedure hich is used t" thr" "ne err"r numer and err"r

message t" the calling en$ir"nment

• t internall% per!"rmance r"lls ack

• /RR+R numer sh"uld e range "! -20000 t" -20??? /RR+R message sh"uld e displa%ed less

then "r e8ual t" ;2 characters

Declare

Psal empsal_TH)/

1egin

D1MSP+#T)#T)#TPN/(L=elc"me'

nsert NT+ dept $alues (0>,arun,<0'

Select sal NT+ Psal !r"m emp here empn" <6?>

G Psal V 2000 TA/N

RS/P))&T+NP/RR+R(-20;0, LS S T++ AA'

/ND G

D1MSP+#T)#T)#TPN/(LTA/ S SX^^PS'

/ND

4

;4

Page 141: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 141/238

RES%,T:

Thus the )4S7 l"ck that handles all t%pes "! e9cepti"ns has een $eri!ied and e9ecuted

success!ull%

Creat"on o& #rocedures)

E1: (o: D

  : :  

&M:

T" rite a )4S7 l"ck t" displa% the student name, marks h"se a$erage mark is a"$e 60_

&,6ORTHM:

STEP: Start the pr"gram

STEP<: &reate a tale ith tale name studPe9am

STEP=: nsert the $alues int" the tale and &alculate t"tal and a$erage "! each student

STEP>: /9ecute the pr"cedure !uncti"n the student h" get a"$e 60_

STEP?: Displa% the t"tal and a$erage "! student

STEP@: Terminate the applicati"n

;4

Page 142: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 142/238

S(T&7

&R/T/ Y+R R/)&/Z )R+&/D#R/ name Y(parameterY,parameter, Z'Z

[S^S\

Yl"cal declarati"nsZ

1/N

e9ecutale statements

Y/E&/)T+N

e9cepti"n handlersZ

/ND YnameZ

E7EC%TO(:

S7V S/T S/R./R+#T)#T +N

0 PRO6R&M:

PROCE)%RE %S(6 POSTO(&, P&R&METERS:

SETT(6 SER!ERO%TP%T O(:

S7V S/T S/R./R+#T)#T +N

S7V &R/T/ +R R/)&/ )R+&/D#R/ )R+& S

1/N

D1MSP+#T)#T)#TPN/(IAell" !r"m pr"cedureI'

/ND

4

O#t2#t:

;4

Page 143: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 143/238

)r"cedure created

S7V /E/&#T/ )R+&

Aell" !r"m pr"cedure

)4S7 pr"cedure success!ull% c"mpleted

0 PRO6R&M:

+: PROCE)%RE %S(6 (OT&TO(&, P&R&METERS:

S7V &R/T/ +R R/)&/ )R+&/D#R/ )R+&2(N N N#M1/R,N2 N N#M1/R,T+T +#T N#M1/R'

1/N

T+T B N C N2

/ND

4

O#t2#t:

)r"cedure created

S7V .R1/ T N#M1/R 

S7V /E/& )R+&2(33,66,BT'

)4S7 pr"cedure success!ull% c"mpleted

S7V )RNT T

T

----------

??

;4

Page 144: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 144/238

Page 145: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 145/238

end

4

O#t 2#t:

/nter $alue !"r aB >

"ld >B aB5a

ne >B aB>

/nter $alue !"r B 6

"ld ?B B5

ne ?B B6

)r"cedure created

S7V set ser$er"utput "n

S7V e9ecute pr"

&D is

>

RES%,T:

;4

Page 146: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 146/238

Thus the implementati"n "! )4S7 pr"cedure has een $eri!ied and e9ecuted success!ull%

C+,AT-.N ./ DATABAS, T+-00,+S AND /UNCT-.NS

D. m2lementation of Tri--er" and it" &22lication

E1: (o: D

  : :  

&M:

T" the mplementati"n "! Triggers !"r the purp"se "! m"nit"r the dataase "@ect(taleetc' !"r an

m"di!icati"n % the 8uer% user and4"r the pplicati"n pr"gram

&,6ORTHM:

Start the pr"gram

2 &reate the tale ith its essential attriutes

3 nsert attriute $alues int" the tale

: &reate the trigger !"r a particular tale

; Speci!% hen the trigger is t" e !ired - e!"re "r a!ter 

6 Speci!% DM statement that in$"kes the trigger - #)DT/, D//T/, "r NS/RT

< Speci!% the t%pe "! triger hether r"-le$el trigger "r n"t

> &"nditi"n t" !ilter r"s

? )4S7 l"ck that is t" e e9ecuted hen trigger is !ired

0 M"di!% the speci!ied tale t" !ire the trigger

Displa% the trigger message !"r the particular kind "! m"di!icati"n

2 St"p the pr"gram

;4

Page 147: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 147/238

)&T&B&SE TR66ERS

Triggers are similar t" pr"cedures "r !uncti"ns in that the% are named )4S7 l"cks it

declarati$e, e9ecutale, and e9cepti"n handling secti"ns trigger is e9ecuted implicitl% hene$er th

triggering e$ent happens The act "! e9ecuting a trigger is kn"n as !iring the trigger

%SE OF TR66ERS

• Maintaining c"mple9 integrit% c"nstraints n"t p"ssile thr"ugh declarati$e c"nstraints enale at tal

creati"n

• uditing in!"rmati"n in a tale % rec"rding the changes made and h" made them

• ut"maticall% signaling "ther pr"grams that acti"n needs t" take place hen chages are made t" a

tale

• )er!"rm $alidati"n "n changes eing made t" tales

• ut"mate maintenance "! the dataase

RESTRCTO(S O( TR66ERES

• ike packages, triggers must e st"red as stand-al"ne "@ects in the dataase and cann"t e l"cal t"

 l"ck "r package

• trigger d"es n"t accept arguments

TPES OF TR66ERS

• DM Triggers

• nstead "! Triggers

• DD Triggers

S%stem Triggers

• Suspend Triggers

C&TE6ORES

Timing -- 1e!"re "r !ter 

e$el -- R" "r Statement

;4

Page 148: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 148/238

• R" le$el trigger !ires "nce !"r each r" a!!ected % the triggering statement R" le$el trigger is

identi!ied % the G+R /&A R+= clause

• Statement le$el trigger !ires "nce either e!"re "r a!ter the statement

TR66ER S(T&7

&R/T/ Y+R R/)&/Z TR/R trigername

[1/G+R/ ̂ GT/R\

[D//T/ ^ NS/RT ^ #)DT/ Y+G c"lumnsZ\

Y+R [D//T/ ^ NS/RT ^#)DT/ Y+G c"lumnsZ\Z

+N tale

YG+R /&A R+= Y=A/N c"nditi"nZZ

YR/G/R/N&N Y+D S "ldZ YN/= S neZZ

)4S7 l"ck 

)M, TR66ERS

• DM trigger is !ired "n an NS/RT, #)DT/, "r D//T/ "perati"n "n a dataase tale t can

 e !ired either e!"re "r a!ter the statement e9ecutes, and can e !ired "nce per a!!ected r", "r "nce

 per statement

• The c"minati"n "! these !act"rs determines the t%pes "! the triggers These are a t"tal "! 2 p"ssil

t%pes (3 statements Q 2 timing Q 2 le$els'

OR)ER OF )M, TR66ER FR(6

• 1e!"re statement le$el

• 1e!"re r" le$el

• !ter r" le$el

• !ter statement le$el

E1:

Supp"se e ha$e a !"lling tale

S7V select Q !r"m student

 N+ NM/ MRKS

----- ---------- ------------

a 00

2 200

;4

Page 149: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 149/238

3 c 300

: d :00

ls" e ha$e triggeringP!iringP"rder tale ith !iringP"rder as the !ield

E1:

&R/T/ +R R/)&/ TR/R TR/R

 e!"re insert "n student

1/N

insert int" triggerP!iringP"rder $alues(I1e!"re Statement e$elI'

/ND TR/R

E1:

&R/T/ +R R/)&/ TR/R TR/R2

 e!"re insert "n student

!"r each r"

1/N

insert int" triggerP!iringP"rder $alues(I1e!"re R" e$elI'

/ND TR/R2

E1:

&R/T/ +R R/)&/ TR/R TR/R3

a!ter insert "n student

1/N

insert int" triggerP!iringP"rder $alues(I!ter Statement e$elI'

/ND TR/R3

E1:

&R/T/ +R R/)&/ TR/R TR/R:

a!ter insert "n student

!"r each r"

1/N

insert int" triggerP!iringP"rder $alues(I!ter R" e$elI'

/ND TR/R:

O#t2#t:

S7V select Q !r"m triggerP!iringP"rder

n" r"s selected

S7V insert int" student $alues(;,IeI,;00'

;4

Page 150: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 150/238

r" created

S7V select Q !r"m triggerP!iringP"rder

GRNP+RD/R 

--------------------------------------------------1e!"re Statement e$el

1e!"re R" e$el

!ter R" e$el!ter Statement e$el

S7V select Q !r"m student

 N+ NM/ MRKS

----- ------------ -------------- a 00

2 200

3 c 300

: d :00; e ;00

E1:

Supp"se e ha$e a tale called marks ith !ields n", "ldPmarks, nePmarks

&R/T/ +R R/)&/ TR/R +DPN/=

 e!"re insert "r update "r delete "n student

!"r each r"

1/N

insert int" marks $alues(B"ldn",B"ldmarks,Bnemarks'

/ND +DPN/=

O#t2#t:

S7V select Q !r"m student

 N+ NM/ MRKS

----- ------- - --------- a 00

2 200

3 c 300

: d :00

; e ;00

S7V select Q !r"m marks

n" r"s selected

;5

Page 151: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 151/238

S7V insert int" student $alues(6,I!I,600'

r" created

S7V select Q !r"m student

 N+ NM/ MRKS

----- ----------- --------------

a 00

2 200

3 c 300

: d :00; e ;00

6 ! 600

S7V select Q !r"m marks

 N+ +DPMRKS N/=PMRKS

---- ------------------- -------------------

600

S7V update student set marks;;; here n";

r" updated

S7V select Q !r"m student

 N+ NM/ MRKS

----- ------- ----------

a 00

2 200

3 c 300

: d :00

; e ;;;6 ! 600

S7V select Q !r"m marks N+ +DPMRKS N/=PMRKS

------ ---------------- ---------------600

; ;00 ;;;

S7V delete student here n" 2

r" deleted

S7V select Q !r"m student

 N+ NM/ MRKS

------ -------------- ------------

a 00

3 c 300

: d :00

; e ;;;

6 ! 600

S7V select Q !r"m marks N+ +DPMRKS N/=PMRKS

----- -------------- ----------------

600

;5

Page 152: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 152/238

; ;00 ;;;

2 200

REFERE(C(6 C,&%SE

! desired, %"u can use the R/G/R/N&N clause t" speci!% a di!!erent name !"r B"ld ane Bne

This clause is !"und a!ter the triggering e$ent, e!"re the =A/N clause

Snta1:

R/G/R/N&N Y"ld as "ldPnameZ Yne as nePnameZ

E1:

&R/T/ +R R/)&/ TR/R R/G/R/N&/PTR/R 

 e!"re insert "r update "r delete "n student

re!erencing "ld as "ldPstudent ne as nePstudent

!"r each r"

1/N

insert int"marks $alues(B"ldPstudentn",B"ldPstudentmarks,BnePstudentmarks'

/ND R/G/R/N&/PTR/R

9HE( C,&%SE

=A/N clause is $alid !"r r"-le$el triggers "nl% ! present, the trigger "d% ill e e9ecuted

"nl% !"r th"se r"s that meet the c"nditi"n speci!ied % the =A/N clause

Snta1:

=A/N tri!!er_condition

=here tri!!er_condition is a 1""lean e9pressi"n t ill e e$aluated !"r each r" The "new

and "old rec"rds can e re!erenced inside tri!!er_condition as ell, ut like R/G/R/N&N, the

c"l"n is n"t used there The c"l"n is "nl% $alid in the trigger "d%

E1:

&R/T/ +R R/)&/ TR/R =A/NPTR/R 

 e!"re insert "r update "r delete "n student

re!erencing "ld as "ldPstudent ne as nePstudent

!"r each r"

hen (nePstudentmarks V ;00'

1/N

insert int"

marks $alues(B"ldPstudentn",B"ldPstudentmarks,BnePstudentmarks'

/ND =A/NPTR/R

;5

Page 153: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 153/238

TR66ER PRE)C&TES

There are three 1""lean !uncti"ns that %"u can use t" determine hat the "perati"n is

The predicates are

• NS/RTN

• #)DTN

• D//TN

E1:

&R/T/ +R R/)&/ TR/R )R/D&T/PTR/R 

 e!"re insert "r update "r delete "n student

1/N

i! inserting then

insert int" predicates $alues(II'

elsi! updating theninsert int" predicates $alues(I#I'

elsi! deleting then

insert int" predicates $alues(IDI'

end i!

/ND )R/D&T/PTR/R

O#t2#t:

S7V delete student here n"

r" deleted

S7V select Q !r"m predicates

MS

---------------

D

S7V insert int" student $alues(<,IgI,<00' r" created

S7V select Q !r"m predicates

MS

---------------

D

;5

Page 154: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 154/238

S7V update student set marks <<< here n"<

r" updated

S7V select Q !r"m predicates

MS

---------------

D

#

(STE&)3OF TR66ERS

nstead-"! triggers !ire instead "! a DM "perati"n ls", instead-"! triggers can e de!ined "nl% "n

$ies nstead-"! triggers are used in t" casesB

• T" all" a $ie that "uld "therise n"t e m"di!iale t" e m"di!ied

• T" m"di!% the c"lumns "! a nested tale c"lumn in a $ie

RES%,T:

Thus the mplementati"n "! Triggers and its applicati"ns t" m"nit"r the m"di!icati"n in dataase ha

 een $eri!ied and e9ecuted success!ull%

D.< MP,EME(T&TO( OF F%(CTO(S &() TS &PP,C&TO(

;5

Page 155: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 155/238

Page 156: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 156/238

!uncti"n is similar t" pr"cedure, e9cept that it returns a $alue The calling pr"gram sh"uld

use the $alue returned % the !uncti"n

CRE&TE F%(CTO(

The create f#nction c"mmand is used t" create a st"red !uncti"n

SYNTA:

&R/T/ Y+R R/)&/Z G#N&T+N name

Y(parameterY,parameter, Z'Z

RET%R( datat2e

[S ^ S\

Yl"cal declarati"nsZ

1/N

e9ecutale statementsRET%R( 5al#e

Y/E&/)T+N

e9cepti"n handlersZ

/ND YnameZ

(ote:

• OR REP,&CE is used t" create a !uncti"n e$en th"ugh a !uncti"n ith the same name alread%

e9ists

• RET%R( datat2e speci!ies the t%pe "! data t" e returned % the !uncti"n

• RET%R( statement in the e9ecutale part returns the $alue The $alue must e "! the same t%pe a

the return t%pe speci!ied using R/T#RN "pti"n in the header

•#ser-de!ined )4S7 !uncti"ns can e used in S7 in the same manner as the standard !uncti"n

such as R+#ND and S#1STR 

+ : T" rite a )4S7 l"ck t" implementati"n "! !act"rial using !uncti"n

0 PRO6R&M:

;5

Page 157: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 157/238

S7Vcreate !uncti"n !n!act(n numer'

return numer is

  numer

 egin

 B

!"r i in n

l""p

 BQi

end l""p

return

end

4

S7VDeclare

n numerB5n

% numer

 egin

dmsP"utputputPline(%'

end

4

O#t2#t:

Guncti"n created

/nter $alue !"r nB ;

old <: n numerB5n

new <: n numerB;

20

)4S7 pr"cedure success!ull% c"mpleted

+<:create a !uncti"n hich c"unt t"tal n""! empl"%ees ha$ing salar% less than 6000

4f#nction $od4

&reate "r replace !uncti"n c"untPemp(esal numer'return numer as

&urs"r $inPcur as Select empn",sal !r"m emp

;5

Page 158: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 158/238

En" empempn"_t%pe

Esal empsal_t%pe

& numer

1egin

+pen $inPcur

&B0

l""p

!etch $inPcur int" 9n",9sal

i!(9salUesal' then

cBcC

end i!

  e9it hen $inPcur_n"t!"und

end l""p

cl"se $inPcur

return c

end

4

Guncti"n created

4f#nction "2ecification4

Declare

 Ne numer

Esal numer

1egin

 NeBc"untPemp(9sal'

DmsP"utputputPline(9sal'

DmaP"utputputPline(Lthere are L^^ne^^empl"%ees'

/nd

4

O%TP%T

There are > empl"%ees

+<: T" rite a )4S7 !uncti"n t" search an address !r"m the gi$en dataase

0 PRO6R&M

S7V create tale ph"ne""k (ph"nePn" numer (6' primar% ke%,

username $archar2(30',

d""rn" $archar2(0',

;5

Page 159: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 159/238

street $archar2(30',

 place $archar2(30',

 pinc"de char(6''

  tale created

S7V insert int" ph"ne""k $alues(2032,I$i@a%I,I204;DI,Iharathi streetI,IN+c"l"n%I,I62?002I'

r" created

S7V insert int" ph"ne""k $alues(2?:6<,I$asanthI,I3?D:I,IRK ha$anI,Isarakkal $ilaiI,I62?002I'

r" created

S7V select Q !r"m ph"ne""k

)A+N/PN+ #S/RNM/ D++RN+ STR//T )&/ )N&+D/

--------------- ---------------- ------------- ----------- ---------- --------------

2032 $i@a% 204;D harathi street N+ c"l"n% 62?002

2?:6< $asanth 3?D: RK ha$an sarakkal $ilai 62?002

S7V create "r replace !uncti"n !indddress(ph"ne in numer' return $archar2 as address $archar2(00'

 egin

select username^^I,I^^d""rn" ^^I,I^^street ^^I,I^^place^^I,I^^pinc"de int" address !r"m ph"ne""k 

here ph"nePn"ph"ne

return address

e9cepti"n

hen n"PdataP!"und then return Iaddress n"t !"undI

end

4

Guncti"n created

declare

address $archar2(00'

 egin

addressB!indaddress(2032'

dmsP"utputputPline(address'

;5

Page 160: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 160/238

end

4

O%TP%T :

.i@a%,204;D,harathi street,N+ c"l"n%,62?002

)4S7 pr"cedure success!ull% c"mpleted

declare

address $archar2(00'

 egin

addressB!indaddress(23;;6'

dmsP"utputputPline(address'

end

 4

O%TP%T<:

ddress n"t !"und

)4S7 pr"cedure success!ull% c"mpleted

Re"#ltB

Thus the implementati"n "! !uncti"ns and its applicati"ns has een e9ecuted success!ull%

SU##L,M,NT - A

  BMS LAB 11A $U,ST.NS

=hat is dataase]

;6

Page 161: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 161/238

dataase is a l"gicall% c"herent c"llecti"n "! data ith s"me inherent meaning, representing s"m

aspect "! real "rld and hich is designed, uilt and p"pulated ith data !"r a speci!ic purp"se

2 =hat is D1MS]

t is a c"llecti"n "! pr"grams that enales user t" create and maintain a dataase n "ther "rds it i

general-purp"se s"!tare that pr"$ides the users ith the pr"cesses "! de!ining, c"nstructing anmanipulating the dataase !"r $ari"us applicati"ns

3 =hat is a Dataase s%stem]

The dataase and D1MS s"!tare t"gether is called as Dataase s%stem

: =hat are the ad$antages "! D1MS]

Redundanc% is c"ntr"lled

2 #nauth"rised access is restricted

3 )r"$iding multiple user inter!aces

: /n!"rcing integrit% c"nstraints

; )r"$iding ackup and rec"$er%

; =hat is the disad$antage in Gile )r"cessing S%stem]

Data redundanc% and inc"nsistenc%

2 Di!!icult in accessing data

3 Data is"lati"n

: Data integrit%

; &"ncurrent access is n"t p"ssile

6 Securit% )r"lems

6 Descrie the three le$els "! data astracti"n]

The are hree le$els "! astracti"nB

)h%sical le$elB The l"est le$el "! astracti"n descries h" data are st"red

;6

Page 162: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 162/238

2 "gical le$elB The ne9t higher le$el "! astracti"n, descries hat data are st"red in dataase an

hat relati"nship am"ng th"se data

3 .ie le$elB The highest le$el "! astracti"n descries "nl% part "! entire dataase

< De!ine the integrit% rules]

There are t" ntegrit% rules

/ntit% ntegrit%B States that )rimar% ke% cann"t ha$e N# $alue

2 Re!erential ntegrit%B States that G"reign Ke% can e either a N# $alue "r sh"uld

)rimar% Ke% $alue "! "ther relati"n

> =hat is e9tensi"n and intensi"n]

/9tensi"nB t is the numer "! tuples present in a tale at an% instance This is time dependent

2 ntensi"nB t is a c"nstant $alue that gi$es the name, structure "! tale and the c"nstraints laid "n i

? =hat is S%stem R] =hat are its t" ma@"r sus%stems]

S%stem R as designed and de$el"ped "$er a peri"d "! ?<:-<? at 1M San "se Research &enter

is a pr"t"t%pe and its purp"se as t" dem"nstrate that it is p"ssile t" uild a Relati"nal S%stem that can

used in a real li!e en$ir"nment t" s"l$e real li!e pr"lems, ith per!"rmance at least c"mparale t" that "e9isting s%stem

ts t" sus%stems are

Research St"rage

2 S%stem Relati"nal Data S%stem

0 A" is the data structure "! S%stem R di!!erent !r"m the relati"nal structure]

#nlike Relati"nal s%stems in S%stem R 

D"mains are n"t supp"rted

2 /n!"rcement "! candidate ke% uni8ueness is "pti"nal

;6

Page 163: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 163/238

3 /n!"rcement "! entit% integrit% is "pti"nal

: Re!erential integrit% is n"t en!"rced

=hat is Data ndependence]

Data independence means that the applicati"n is independent "! the st"rage structure and acces

strateg% "! data n "ther "rds, The ailit% t" m"di!% the schema de!initi"n in "ne le$el sh"uld n"t a!!ec

the schema de!initi"n in the ne9t higher le$el

T" t%pes "! Data ndependenceB

)h%sical Data ndependenceB M"di!icati"n in ph%sical le$el sh"uld n"t a!!ect the l"gical le$el

2 "gical Data ndependenceB M"di!icati"n in l"gical le$el sh"uld a!!ect the $ie le$el

 N+T/B "gical Data ndependence is m"re di!!icult t" achie$e

2 =hat is a $ie] A" it is related t" data independence]

$ie ma% e th"ught "! as a $irtual tale, that is, a tale that d"es n"t reall% e9ist in its "n righ

 ut is instead deri$ed !r"m "ne "r m"re underl%ing ase tale n "ther "rds, there is n" st"red !ile tha

direct represents the $ie instead a de!initi"n "! $ie is st"red in data dicti"nar%

r"th and restructuring "! ase tales is n"t re!lected in $ies Thus the $ie can insulate user!r"m the e!!ects "! restructuring and gr"th in the dataase Aence acc"unts !"r l"gical data independence

3 =hat is Data M"del]

c"llecti"n "! c"nceptual t""ls !"r descriing data, data relati"nships data semantics an

c"nstraints

: =hat is /-R m"del]

This data m"del is ased "n real "rld that c"nsists "! asic "@ects called entities and "

relati"nship

am"ng these "@ects /ntities are descried in a dataase % a set "! attriutes

; =hat is +@ect +riented m"del]

;6

Page 164: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 164/238

This m"del is ased "n c"llecti"n "! "@ects n "@ect c"ntains $alues st"red in instance $ariale

ith in the "@ect n "@ect als" c"ntains "dies "! c"de that "perate "n the "@ect These "dies "! c"d

are called meth"ds +@ects that c"ntain same t%pes "! $alues and the same meth"ds are gr"uped t"gethe

int" classes

6 =hat is an /ntit%]

t is a IthingI in the real "rld ith an independent e9istence

< =hat is an /ntit% t%pe]

t is a c"llecti"n (set' "! entities that ha$e same attriutes

> =hat is an /ntit% set]

t is a c"llecti"n "! all entities "! particular entit% t%pe in the dataase

? =hat is an /9tensi"n "! entit% t%pe]

The c"llecti"ns "! entities "! a particular entit% t%pe are gr"uped t"gether int" an entit% set

20 =hat is =eak /ntit% set]

n entit% set ma% n"t ha$e su!!icient attriutes t" !"rm a primar% ke%, and its primar% ke

c"mpr"mises "! its partial ke% and primar% ke% "! its parent entit%, then it is said t" e =eak /ntit% set

2 =hat is an attriute]

t is a particular pr"pert%, hich descries the entit%

22 =hat is a Relati"n Schema and a Relati"n]

relati"n Schema den"ted % R(, 2, , n' is made up "! the relati"n name R and the list "

attriutes i that it c"ntains relati"n is de!ined as a set "! tuples et r e the relati"n hich c"ntains se

tuples (t, t2, t3, , tn' /ach tuple is an "rdered list "! n-$alues t($,$2, , $n'

23 =hat is degree "! a Relati"n]

t is the numer "! attriute "! its relati"n schema

;6

Page 165: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 165/238

2: =hat is Relati"nship]

t is an ass"ciati"n am"ng t" "r m"re entities

2; =hat is Relati"nship set]

The c"llecti"n ("r set' "! similar relati"nships

26 =hat is Relati"nship t%pe]

Relati"nship t%pe de!ines a set "! ass"ciati"ns "r a relati"nship set am"ng a gi$en set "! entit% t%pes

2< =hat is degree "! Relati"nship t%pe]

t is the numer "! entit% t%pe participating

2> =hat is DD (Data De!initi"n anguage']

data ase schema is speci!ies % a set "! de!initi"ns e9pressed % a special language called DD

2? =hat is .D (.ie De!initi"n anguage']

t speci!ies user $ies and their mappings t" the c"nceptual schema

30 =hat is SD (St"rage De!initi"n anguage']

This language is t" speci!% the internal schema This language ma% speci!% the mapping eteen t

schemas

3 =hat is Data St"rage - De!initi"n anguage]

The st"rage structures and access meth"ds used % dataase s%stem are speci!ied % a set "

de!initi"n in a special t%pe "! DD called data st"rage-de!initi"n language

32 =hat is DM (Data Manipulati"n anguage']

This language that enale user t" access "r manipulate data as "rganised % appr"priate data m"del

;6

Page 166: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 166/238

)r"cedural DM "r " le$elB DM re8uires a user t" speci!% hat data are needed and h" t

get th"se data

2 N"n-)r"cedural DM "r Aigh le$elB DM re8uires a user t" speci!% hat data are needed ith"u

speci!%ing h" t" get th"se data

33 =hat is DM &"mpiler]

t translates DM statements in a 8uer% language int" l"-le$el instructi"n that the 8uer% e$aluati"n

engine can understand

3: =hat is 7uer% e$aluati"n engine]

t e9ecutes l"-le$el instructi"n generated % c"mpiler

3; =hat is DD nterpreter]

t interprets DD statements and rec"rd them in tales c"ntaining metadata

36 =hat is Rec"rd-at-a-time]

The " le$el "r )r"cedural DM can speci!% and retrie$e each rec"rd !r"m a set "! rec"rds Thi

retrie$e "! a rec"rd is said t" e Rec"rd-at-a-time

3< =hat is Set-at-a-time "r Set-"riented]

The Aigh le$el "r N"n-pr"cedural DM can speci!% and retrie$e man% rec"rds in a single DM

statement This retrie$e "! a rec"rd is said t" e Set-at-a-time "r Set-"riented

3> =hat is Relati"nal lgera]

t is pr"cedural 8uer% language t c"nsists "! a set "! "perati"ns that take "ne "r t" relati"ns a

input and pr"duce a ne relati"n

3? =hat is Relati"nal &alculus]

t is an applied predicate calculus speci!icall% tail"red !"r relati"nal dataases pr"p"sed % /G

&"dd

;6

Page 167: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 167/238

/g "! languages ased "n it are DS )A, 7#/

:0 A" d"es Tuple-"riented relati"nal calculus di!!er !r"m d"main-"riented relati"nal calculus]

The tuple-"riented calculus uses a tuple $ariales ie, $ariale h"se "nl% permitted $alues ar

tuples "! that relati"n /g 7#/

2 The d"main-"riented calculus has d"main $ariales ie, $ariales that range "$er the underl%in

d"mains instead "! "$er relati"n /g , D/D#&/

: =hat is n"rmaliFati"n]

t is a pr"cess "! anal%sing the gi$en relati"n schemas ased "n their Guncti"nal Dependencies (GDs

and primar% ke% t" achie$e the pr"perties

('MinimiFing redundanc%,

(2' MinimiFing inserti"n, deleti"n and update an"malies

:2 =hat is Guncti"nal Dependenc%]

Guncti"nal dependenc% is den"ted % E H eteen t" sets "! attriutes E and H that are suset

"! R speci!ies a c"nstraint "n the p"ssile tuple that can !"rm a relati"n state r "! R The c"nstraint is !"r an

t" tuples t and t2 in r i! tYEZ t2YEZ then the% ha$e tYHZ t2YHZ This means the $alue "! E c"mp"nen

"! a tuple uni8uel% determines the $alue "! c"mp"nent H

:3 =hat is "ssless @"in pr"pert%]

t guarantees that the spuri"us tuple generati"n d"es n"t "ccur ith respect t" relati"n schemas a!te

dec"mp"siti"n

:: =hat is NG (N"rmal G"rm']

The d"main "! attriute must include "nl% at"mic (simple, indi$isile' $alues

:; =hat is Gull% Guncti"nal dependenc%]

t is ased "n c"ncept "! !ull !uncti"nal dependenc% !uncti"nal dependenc% E H is !ull !uncti"na

dependenc% i! rem"$al "! an% attriute !r"m E means that the dependenc% d"es n"t h"ld an% m"re

:6 =hat is 2NG]

;6

Page 168: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 168/238

relati"n schema R is in 2NG i! it is in NG and e$er% n"n-prime attriute in R is !ull

!uncti"nall% dependent "n primar% ke%

:< =hat is 3NG]

relati"n schema R is in 3NG i! it is in 2NG and !"r e$er% GD E either "! the !"ll"ing is true

E is a Super-ke% "! R

2 is a prime attriute "! R

n "ther "rds, i! e$er% n"n prime attriute is n"n-transiti$el% dependent "n primar% ke%

:> =hat is 1&NG (1"%ce-&"dd N"rmal G"rm']

relati"n schema R is in 1&NG i! it is in 3NG and satis!ies an additi"nal c"nstraint that !"r e$er% GD

E , E must e a candidate ke%

:? =hat is :NG]

relati"n schema R is said t" e in :NG i! !"r e$er% Multi$alued dependenc% E H that h"lds "$er R

"ne "! !"ll"ing is true

' E is suset "r e8ual t" ("r' EH R

2' E is a super ke%

;0 =hat is ;NG]

Relati"n schema R is said t" e ;NG i! !"r e$er% @"in dependenc% [R, R2, , Rn\ that h"lds R

"ne the !"ll"ing is true

' Ri R !"r s"me i

2' The @"in dependenc% is implied % the set "! GD, "$er R in hich the le!t side is ke% "! R

; =hat is D"main-Ke% N"rmal G"rm]

;6

Page 169: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 169/238

relati"n is said t" e in DKNG i! all c"nstraints and dependencies that sh"uld h"ld "n the th

c"nstraint can e en!"rced % simpl% en!"rcing the d"main c"nstraint and ke% c"nstraint "n the relati"n

;2 =hat are partial, alternate,, arti!icial, c"mp"und and natural ke%]

. Partial 8e:

t is a set "! attriutes that can uni8uel% identi!% eak entities and that are related t" same "ne

entit% t is s"metime called as Discriminat"r

<. &lternate 8e:

ll &andidate Ke%s e9cluding the )rimar% Ke% are kn"n as lternate Ke%s

=. &rtificial 8e:

! n" "$i"us ke%, either stand al"ne "r c"mp"und is a$ailale, then the last res"rt is t" simpl% creat

a ke%, % assigning a uni8ue numer t" each rec"rd "r "ccurrence Then this is kn"n as de$el"ping a

arti!icial ke%

>. Com2o#nd 8e:

! n" single data element uni8uel% identi!ies "ccurrences ithin a c"nstruct, then c"mining multipl

elements t" create a uni8ue identi!ier !"r the c"nstruct is kn"n as creating a c"mp"und ke%

?. (at#ral 8e:

=hen "ne "! the data elements st"red ithin a c"nstruct is utiliFed as the primar% ke%, then it i

called the natural ke%

;3 =hat is inde9ing and hat are the di!!erent kinds "! inde9ing]

nde9ing is a techni8ue !"r determining h" 8uickl% speci!ic data can e !"und

T%pesB

1inar% search st%le inde9ing

2 1-Tree inde9ing

3 n$erted list inde9ing

;6

Page 170: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 170/238

: Mem"r% resident tale

; Tale inde9ing

;: =hat is s%stem catal"g "r catal"g relati"n] A" is etter kn"n as]

RD1MS maintains a descripti"n "! all the data that it c"ntains, in!"rmati"n a"ut e$er% relati"

and inde9 that it c"ntains This in!"rmati"n is st"red in a c"llecti"n "! relati"ns maintained % the s%stem

called metadata t is als" called data dicti"nar%

;; =hat is meant % 8uer% "ptimiFati"n]

The phase that identi!ies an e!!icient e9ecuti"n plan !"r e$aluating a 8uer% that has the lea

estimated c"st is re!erred t" as 8uer% "ptimiFati"n

;6 =hat is durailit% in D1MS]

+nce the D1MS in!"rms the user that a transacti"n has success!ull% c"mpleted, its e!!ects sh"ul

 persist e$en i! the s%stem crashes e!"re all its changes are re!lected "n disk This pr"pert% is calle

durailit%

;< =hat d" %"u mean % at"micit% and aggregati"n]

. &tomicit:

/ither all acti"ns are carried "ut "r n"ne are #sers sh"uld n"t ha$e t" "rr% a"ut the e!!ect "

inc"mplete transacti"ns D1MS ensures this % und"ing the acti"ns "! inc"mplete transacti"ns

<. &--re-ation:

  c"ncept hich is used t" m"del a relati"nship eteen a c"llecti"n "! entities and relati"nships

is used hen e need t" e9press a relati"nship am"ng relati"nships

;> =hat is a )hant"m Deadl"ck]

n distriuted deadl"ck detecti"n, the dela% in pr"pagating l"cal in!"rmati"n might cause th

deadl"ck detecti"n alg"rithms t" identi!% deadl"cks that d" n"t reall% e9ist Such situati"ns are calle

 phant"m deadl"cks and the% lead t" unnecessar% a"rts

;7

Page 171: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 171/238

;? =hat is a checkp"int and =hen d"es it "ccur]

&heckp"int is like a snapsh"t "! the D1MS state 1% taking checkp"ints, the D1MS can reduc

the am"unt "! "rk t" e d"ne during restart in the e$ent "! suse8uent crashes

60 =hat are the di!!erent phases "! transacti"n]

Di!!erent phases are

' nal%sis phase,

2' Red" )hase,

3' #nd" phase

6 =hat d" %"u mean % !lat !ile dataase]

t is a dataase in hich there are n" pr"grams "r user access languages t has n" cr"ss-!il

capailities ut is user-!riendl% and pr"$ides user-inter!ace management

62 =hat is transparent D1MS]

t is "ne, hich keeps its )h%sical Structure hidden !r"m user

63 =hat is a 8uer%]

8uer% ith respect t" D1MS relates t" user c"mmands that are used t" interact ith a data ase

The 8uer% language can e classi!ied int" data de!initi"n language and data manipulati"n language

6: =hat d" %"u mean % &"rrelated su8uer%]

Su8ueries, "r nested 8ueries, are used t" ring ack a set "! r"s t" e used % the parent 8uer%

Depending "n h" the su8uer% is ritten, it can e e9ecuted "nce !"r the parent 8uer% "r it can e e9ecute

"nce !"r each r" returned % the parent 8uer% ! the su8uer% is e9ecuted !"r each r" "! the parent, this

called a c"rrelated su8uer%

c"rrelated su8uer% can e easil% identi!ied i! it c"ntains an% re!erences t" the parent su8uer% c"lumns i

its =A/R/ clause &"lumns !r"m the su8uer% cann"t e re!erenced an%here else in the parent 8uer% Th

!"ll"ing e9ample dem"nstrates a n"n-c"rrelated su8uer%

;7

Page 172: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 172/238

/9ampleB

Select Q Gr"m &#ST =here I04034??0I N (Select +DT/ Gr"m +RD/R 

=here &#ST&N#M +RD/R&N#M'

6; =hat are the primiti$e "perati"ns c"mm"n t" all rec"rd management s%stems]

dditi"n, deleti"n and m"di!icati"n

66 Name the u!!er in hich all the c"mmands that are t%ped in are st"red]

I/ditI 1u!!er

6< =hat are the unar% "perati"ns in Relati"nal lgera]

)R+/&T+N and S//&T+N

6> re the resulting relati"ns "! )R+D#&T and +N "perati"n the same]

 N"

)R+D#&TB &"ncatenati"n "! e$er% r" in "ne relati"n ith e$er% r" in an"ther

+NB &"ncatenati"n "! r"s !r"m "ne relati"n and related r"s !r"m an"ther

6? =hat is RD1MS K/RN/]

T" imp"rtant pieces "! RD1MS architecture are the kernel, hich is the s"!tare, and the dat

dicti"nar%, hich c"nsists "! the s%stem-le$el data structures used % the kernel t" manage the dataase H"

might think "! an RD1MS as an "perating s%stem ("r set "! sus%stems', designed speci!icall% !"

c"ntr"lling data access its primar% !uncti"ns are st"ring, retrie$ing, and securing data

n RD1MS maintains its "n list "! auth"riFed users and their ass"ciated pri$ileges manages mem"r%

caches and paging c"ntr"ls l"cking !"r c"ncurrent res"urce usage dispatches and schedules user 

re8uests and manages space usage ithin its tale-space structures

<0 Name the su-s%stems "! a RD1MS

4+, Securit%,

;7

Page 173: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 173/238

Page 174: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 174/238

' Dataase !iles

2' &"ntr"l !iles

3' Red" l"gs

The m"st imp"rtant "! these are the dataase !iles here the actual data resides The c"ntr"l !iles an

the red" l"gs supp"rt the !uncti"ning "! the architecture itsel! ll three sets "! !iles must e present, "pen

and a$ailale t" +racle !"r an% data "n the dataase t" e useale =ith"ut these !iles, %"u cann"t access th

dataase, and the dataase administrat"r might ha$e t" rec"$er s"me "r all "! the dataase using a ackup, i

there is "ne

<6 =hat is dataase Trigger]

dataase trigger is a )4S7 l"ck that can de!ined t" aut"maticall% e9ecute !"r insert, update, an

delete statements against a tale The trigger can e de!ined t" e9ecute "nce !"r the entire statement "r "nc

!"r e$er% r" that is inserted, updated, "r deleted G"r an% "ne tale, there are tel$e e$ents !"r hich %"u

can de!ine dataase triggers dataase trigger can call dataase pr"cedures that are als" ritten in )4S7

<< =hat are st"red-pr"cedures] nd hat are the ad$antages "! using them]

St"red pr"cedures are dataase "@ects that per!"rm a user de!ined "perati"n st"red pr"cedure ca

ha$e a set "! c"mp"und S7 statements st"red pr"cedure e9ecutes the S7 c"mmands and returns th

result t" the client St"red pr"cedures are used t" reduce net"rk tra!!ic

<> =hat is St"rage Manager]

t is a pr"gram m"dule that pr"$ides the inter!ace eteen the l"-le$el data st"red in dataase

applicati"n pr"grams and 8ueries sumitted t" the s%stem

<? =hat is 1u!!er Manager]

t is a pr"gram m"dule, hich is resp"nsile !"r !etching data !r"m disk st"rage int" main mem"r%

and deciding hat data t" e cache in mem"r%

>0 =hat is Transacti"n Manager]

t is a pr"gram m"dule, hich ensures that dataase, remains in a c"nsistent state despite s%stem

!ailures and c"ncurrent transacti"n e9ecuti"n pr"ceeds ith"ut c"n!licting

;7

Page 175: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 175/238

> =hat is Gile Manager]

t is a pr"gram m"dule, hich manages the all"cati"n "! space "n disk st"rage and data structur

used t" represent in!"rmati"n st"red "n a disk

>2 =hat is uth"riFati"n and ntegrit% manager]

t is the pr"gram m"dule, hich tests !"r the satis!acti"n "! integrit% c"nstraint and checks th

auth"rit% "! user t" access data

>3 =hat are stand-al"ne pr"cedures]

)r"cedures that are n"t part "! a package are kn"n as stand-al"ne ecause the% independentl

de!ined g""d e9ample "! a stand-al"ne pr"cedure is "ne ritten in a S7QG"rms applicati"n These t%pe

"! pr"cedures are n"t a$ailale !"r re!erence !r"m "ther +racle t""ls n"ther limitati"n "! stand-al"n

 pr"cedures is that the% are c"mpiled at run time, hich sl"s e9ecuti"n

>: =hat are curs"rs gi$e di!!erent t%pes "! curs"rs]

)4S7 uses curs"rs !"r all dataase in!"rmati"n accesses statements The language supp"rts the us

t" t%pes "! curs"rs

' mplicit

2' /9plicit

>; =hat is c"ld ackup and h"t ackup (in case "! +racle']

&"ld 1ackupB t is c"p%ing the three sets "! !iles (dataase !iles, red" l"gs, and c"ntr"l !ile' hen th

instance is shut d"n This is a straight !ile c"p%, usuall% !r"m the disk directl% t" tape H"u must shut d"

the instance t" guarantee a c"nsistent c"p% ! a c"ld ackup is per!"rmed, the "nl% "pti"n a$ailale in th

e$ent "! data !ile l"ss is rest"ring all the !iles !r"m the latest ackup ll "rk per!"rmed "n the dataas

since the last ackup is l"st

2 A"t 1ackupB S"me sites (such as "rldide airline reser$ati"ns s%stems' cann"t shut d"n the dataas

hile making a ackup c"p% "! the !iles The c"ld ackup is n"t an a$ailale "pti"n

>6 =hat is meant % )r"acti$e, Retr"acti$e and Simultane"us #pdate

)r"acti$e #pdateB The updates that are applied t" dataase e!"re it ec"mes e!!ecti$e in real "rld

;7

Page 176: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 176/238

2 Retr"acti$e #pdateB The updates that are applied t" dataase a!ter it ec"mes e!!ecti$e in real "rld

3 Simulatne"us #pdateB The updates that are applied t" dataase at the same time hen it ec"mes e!!ecti$

in real "rld

SU##L,M,NT - B

)&T&B&SE &PP,C&TO(

Em2loee" Mana-ement &22lication

This applicati"n is used t" keep track "! in!"rmati"n a"ut empl"%ees "! a c"mpan% t als" st"re

the in!"rmati"n a"ut departments and lea$es taken % empl"%ees H"u are re8uired t" create tales (a

sh"n el"' and insert data int" each "! the tale

part !r"m gi$ing %"u an idea a"ut h" t" create tales ith c"nstraints, it als" enales %"u t" understan

h" t" create 8ueries, pl4s8l pr"grams, st"red pr"cedures and !uncti"ns and dataase triggers

A"e$er, n"te, this sample c"llecti"n "! tales is "nl% !"r learning purp"se and the% are h%p"thetical

• Re8uired Tales

• Structure "! Tales

;7

Page 177: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 177/238

• &reating Tales

• "ading data int" tales

• 7ueries

Re;#ired Ta$le"

The !"ll"ing are the set "! tales t" e created t" st"re the re8uired in!"rmati"n

Ta$le (ame Meanin-

D/)T St"res the details "! departments "! the c"mpan%

/M)+H// St"res in!"rmati"n a"ut all the empl"%ees "! the c"mpan%

/./S St"res in!"rmati"n a"ut t%pes "! lea$es a$ailale

/M)P/./S St"res in!"rmati"n a"ut lea$es taken % the empl"%ees

Structure "! Tales

The !"ll"ing is the structure "! each "! the re8uired tale

D/)T Tale

St"res in!"rmati"n a"ut all the departments "! the c"mpan%

Col#mn (ame )atat2e Meanin-

D/)TN+ numer(2' Department Numer  

D/)TNM/ $archar2(20' Department Name

A+D $archar2(20' Aead "! the department

Con"traint"

• D/)TN+ is primar% ke%

• D/)TNM/ must e uni8ue

;7

Page 178: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 178/238

EMP,OEE ta$le

&"ntains in!"rmati"n a"ut all the empl"%ees "! the c"mpan%

Col#mn (ame )atat2e Meanin-

/M)N+ numer(;' /mpl"%ee Numer  

/M)NM/ $archar2(20' /mpl"%ee Name

S numer(6' 1asic Salar%

D/)TN+ numer(2' Department t" hich empl"%ee el"ngs

D Date Date "! @"ining the c"mpan%

D/S $archar2(20' Designati"n "! the empl"%ee

Con"traint"

• /M)N+ is primar% ke%

• S must e V 000

• D/)TN+ is !"reign ke% re!erencing D/)TN+ "! D/)T tale

,E&!ES Ta$le&"ntains in!"rmati"n a"ut the t%pes "! lea$es a$ailale in the c"mpan%

Col#mn (ame )atat2e Meanin-

/./TH)/ char(' &"de !"r the t%pe "! lea$e

/./NM/ $archar2(20' Descripti"n "! the t%pe "! the lea$e

 N+/./S numer(2' Numer "! lea$es all"tted t" each empl"%ee !"r a lea$e t%pe

Contraint"

• /./TH)/ is primar% ke%

•  N+/./S must e U 20

EMP,E&!ES Ta$le

&"ntains in!"rmati"n a"ut the lea$es taken % empl"%ees

;7

Page 179: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 179/238

Page 180: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 180/238

  N+/./S N#M1/R(2' &+NSTRNT /./SPN+/./SP&AK &A/&K ( N+/./S U 20'

'

&R/T/ T1/ /M)+H//

(

  /M)N+ N#M1/R(;' &+NSTRNT /M)+H//P)K )RMRH K/H,

  /M)NM/ .R&AR2(20',  S N#M1/R(;' &+NSTRNT /M)+H//PSP&AK &A/&K ( S V 000',

  D/)TN+ N#M1/R(2' &+NSTRNT /M)+H//PD/)TN+PGK R/G/R/N&/S D/)T(D/)TN+',

  D/S .R&AR2(20',

  D DT/,'

&R/T/ T1/ /M)P/./S(

  /M)N+ N#M1/R(;' &+NSTRNT /M)P/./SP/M)N+PGK R/G/R/N&/S /M)+H//(/M)N+',

  /./TH)/ &AR(' &+NSTRNT /M)P/./SP/./TH)/PGK R/G/R/N&/S /./S(/./TH)/'

  &+NSTRNT /M)P/./SP/./TH)/PNN N+T N#,  STDT/ DT/,

  /NDDT/ DT/,

  &+NSTRNT /M)P/./SP)K )RMRH K/H (/M)N+,STDT/',

  &+NSTRNT /M)P/./SPDT/SP&AK &A/&K (STDT/ U /NDDT/''

"ading data int" tales

The !"ll"ing script inserts a !e r"s int" sample tales &lick here t" d"nl"ad the script t"

create sample data "r c"p% the script gi$en el" int" n"tepad, sa$e it ith S7 e9tensi"n and

run it at S7V using STRT c"mmand

R/M QQQQQQ script t" insert sample data int" /M)+H//S applicati"n QQQQQQ

R/M QQQQQQ #TA+R B )SRKNTA QQQQQQR/M QQQQQQ DT/ B 23-#-200 QQQQQQ

R/M QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ

rem rem"$e all e9isting r"s !irst

D//T/ GR+M /M)P/./S

D//T/ GR+M /M)+H//D//T/ GR+M D/)T

D//T/ GR+M /./S

NS/RT NT+ /./S .#/S(ISI,IS&KI,;'

NS/RT NT+ /./S .#/S(I&I,I&S#I,;'

NS/RT NT+ /./S .#/S(I/I,I/RNNI,;'

NS/RT NT+ /./S .#/S(I+I,I+./RTM/I,;'

NS/RT NT+ D/)T .#/S(,IMNGRM/I,I/+R/I'NS/RT NT+ D/)T .#/S(2,I&/NT4S/R./RI,I1I'

NS/RT NT+ D/)T .#/S(3,ISHST/MSI,IRRHI'

NS/RT NT+ D/)T .#/S(:,INT/RN/TI,I)#I'

NS/RT NT+ D/)T .#/S(;,I&&+#NTSI,INDHI'

NS/RT NT+ /M)+H// .#/S(0,I/+R/I,2000,,I2-#-200I,I)MI'

NS/RT NT+ /M)+H// .#/S(02,I1I,2000,2,I:-#-200I,I)MI'NS/RT NT+ /M)+H// .#/S(03,IRRHI,;000,3,I-#-200I,I)MI'

;8

Page 181: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 181/238

NS/RT NT+ /M)+H// .#/S(0:,I)#I,000,:,I2-#-200I,I)I'

NS/RT NT+ /M)+H// .#/S(0;,INDHI,<000,;,I2;-#N-200I,IMI'

NS/RT NT+ /M)+H// .#/S(06,IK/TSI,0000,,I<-#-200I,ISI'

NS/RT NT+ /M)+H// .#/S(0<,I+/I,>000,2,I;-#-200I,IS)I'NS/RT NT+ /M)+H// .#/S(0>,IR+1/RTSI,<;00,2,I;-#-200I,I)R+I'

NS/RT NT+ /M)+H// .#/S(0?,IA/R1/RTI,>000,:,I22-#-200I,ISI'

NS/RT NT+ /M)+H// .#/S(0,IM&A/I,6000,:,I;-#-200I,I)R+I'

NS/RT NT+ /M)P/./S .#/S(02,ISI,I23-#-200I,I2;-#-200I'

NS/RT NT+ /M)P/./S .#/S(0:,I&I,I2:-#-200I,I2;-#-200I'

NS/RT NT+ /M)P/./S .#/S(0:,ISI,I2>-#-200I,I2?-#-200I'NS/RT NT+ /M)P/./S .#/S(0,I&I,I2<-#-200I,I2>-#-200I'

NS/RT NT+ /M)P/./S .#/S(06,I+I,I2>-#-200I,I2?-#-200I'

NS/RT NT+ /M)P/./S .#/S(0?,I&I,I-#-200I,I2-#-200I'

NS/RT NT+ /M)P/./S .#/S(03,I&I,I2-#-200I,I;-#-200I'NS/RT NT+ /M)P/./S .#/S(0;,ISI,I<-#-200I,N#'

NS/RT NT+ /M)P/./S .#/S(0>,ISI,I23-#-200I,N#'

&+MMT

$uer"es +elated To ,m(lo'ees Management A((l"cat"on

+: DS)H /M)+H//S =A+ A./ +N/D N TA/ ST ; DHS

S//&T Q GR+M /M)+H//

=A/R/ SHSDT/ - D U ;

 +: DS)H /M)+H//S =A+ A./ +N/D T+DH

S//&T Q GR+M /M)+H//

=A/R/ TR#N&(SHSDT/' TR#N&(D'

(OTE:

TR#N& G#N&T+N S R/7#R/D N +RD/R T+ N+R/ TM/ DGG/R/N&/ 1/T=//N T=+ DT/S

+: DS)H =A+ A./ +N/D N TA/ ST =//K +G TA/ M+NTA

S//&T Q GR+M /M)+H//

=A/R/ D V STPDH(D' - <

+: DS)H =A/N /M)+H// 02 AS TK/N AS GRST SRH

S//&T /M)NM/, STPDH(D' C GRST SRH DT/

GR+M /M)+H//

=A/R/ /M)N+ 02

+: D//T/ /M)+H//S =A+ A./ +N/D TA/ &#RR/NT M+NTA

D//T/ GR+M /M)+H// =A/R/ T+P&AR(SHSDT/,IMMHHHHI' T+P&AR(D,IMMHHHHI'

;8

Page 182: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 182/238

+: D/TS +G /M)+H//S =A+S/ SRH RN/ S 1/T=//N 2,000 T+ :,000

S//&T Q GR+M /M)+H//

=A/R/ S 1/T=//N 2000 ND :000

+: D/TS +G /M)+H//S =A+ 1/+N T+ D/)RTM/NT +R 3

S//&T Q GR+M /M)+H//

=A/R/ D/)TN+ N (,3'

+: S//&T NM/S +G /M)+H//S =A+S/ NM/S STRT =TA IMI

S//&T /M)NM/

GR+M /M)+H// =A/R/ /M)NM/ K/ IM_I

+: D//T/ TA+S/ /M)+H//S =A/R/ NM/ AS TA/ &AR&T/R II

D//T/ GR+M /M)+H//

=A/R/ /M)NM/ K/ I__I

+: S//&T /M)+H//S =A/R/ S/&+ND &AR&T/R N NM/ S ISI

S//&T Q GR+M /M)+H//

=A/R/ /M)NM/ K/ IPS_I

+: S//&T TA+S/ /M)+H//S =A+S/ SRH S N+T KN+=N

S//&T Q GR+M /M)+H//

=A/R/ S S N#

+: DS)H TA/ D/TS +G /M)+H//S =A+ A./ +N/D N TA/ ST 20 DHS

S//&T Q GR+M /M)+H//

=A/R/ SHSDT/ - D U 20

+: DS)H TA/ D/TS +G /./S G TA/ N#M1/R +G /./S S M+R/ TAN 0

S//&T Q GR+M /M)P/./S

=A/R/ /NDDT/ - STDT/ V 0

+: DS)H /M)N+,/M)NM/,DT/ +G +NN,N#M1/R +G M+NTAS +G /E)/R/N&/ ND 1S& SRH

S//&T /M)N+, /M)NM/, D, M+NTASP1/T=//N(SHSDT/,D' /E), S

GR+M /M)+H//

+: DS)H D/TS +G /M)+H//S =A+ R/ DR=N M+R/ TAN 0000 ND TA/ D/SNT+N S &+NTNN

M+R/ TAN 3 /TT/RS

S//&T Q GR+M /M)+H//

=A/R/ S V 0000 ND /NTA(D/S' V 3

+: DS)H D/TS +G /M)+H//S =A+S/ NM/ S &+NTNN M+R/ TAN +N/ S)&/

;8

Page 183: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 183/238

S//&T Q GR+M /M)+H//

=A/R/ NSTR(/M)NM/, I I , , 2' UV 0

+: DS)H D/TS +G /./S =A/R/ TA/ /./ STRT/D N TA/ )R/.+#S M+NTA ND TA/ /./ S N+T H/T

&+M)/T/D

S//&T Q GR+M /M)P/./S

=A/R/ STDT/ 1/T=//N STPDH( DDPM+NTAS(STDT/,-2'' C ND

STPDH( DDPM+NTAS(STDT/,-'' C

ND /NDDT/ S N#

+: DS)H D/TS +G /M)+H//S =A/R/ 1S& SRH S M+R/ TAN 0000 +R D/SNT+N S ) ND

/E)/R/N&/ S M+R/ TAN 3 H/RS

S//&T Q GR+M /M)+H//

=A/R/ S V 0000 +R D/S I)I ND M+NTASP1/T=//N(SHSDT/,D' V 36

+: DS)H /M)N+,NM/ ND GRST NM/ +G TA/ /M)+H// ND =A/N /M)+H// AS TK/N AS GRST SRH

S//&T S#1STR(/M)NM/,,NSTR(/M)NM/,I I' -' GNM/, STPDH(D' C

GR+M /M)+H//

+: GND TA/ ./R/ SRH +G TA/ /M)+H// =A+ +N/D N TA/ &#RR/NT H/R 

S//&T .(S'

GR+M /M)+H//

=A/R/ T+P&AR(D,IHHHHI' T+P&AR(SHSDT/,IHHHHI'

+: GND TA/ ./R/ SRH +G /&A D/)RTM/NT 1H TKN /M)+H//S =A+ /RN M+R/ TAN 0000

S//&T D/)TN+, .(S'

GR+M /M)+H//

=A/R/ S V 0000

R+#) 1H D/)TN+

+: DS)H D/TS +G /M)+H//S +N =TA 1+N#S =A&A = 1/ 00_ +N SRH G+R /M)+H//S +G

D/)RTM/NT ND <;_ G+R +TA/RS

S//&T /M)N+, /M)NM/, D/S, D, S, S Q D/&+D/(D/)TN+,,0,0<;' 1+N#S

GR+M /M)+H//

+: DS)H D/TS +G /./S TK/N 1H /M)+H//S =A/R/ TH)/ +G /./ S ISI ND /./ STRT/D +N M+NDH

S//&T Q GR+M /M)P/./S

=A/R/ /./TH)/ ISI ND T+P&AR(STDT/,I!mDHI' IM+NDHI

+: DS)H /M)N+ ND N+ +G /./S TK/N 1H /M)+H//

S//&T /M)N+, S#M(/NDDT/-STDT/' N+ /./S

;8

Page 184: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 184/238

GR+M /M)P/./S

R+#) 1H /M)N+

+: DS)H D/SNT+N ND T+T SRH +G TA/ /M)+H//S +G D/SNT+N

S//&T D/S,S#M(S'

GR+M /M)+H//

R+#) 1H D/S

+: GND TA/ S#M +G SR/S N /&A D/SNT+N N /&A D/)RTM/NT

S//&T D/)TN+, D/S, S#M(S'

GR+M /M)+H//

R+#) 1H D/)TN+, D/S

+: GND TA/ ./R/ SRH +G /&A D/)RTM/NT ND S//&T +NH TA+S/ /M)+H//S A.N SRH M+R/TAN 0000

S//&T D/)TN+, .(S'

GR+M /M)+H//

=A/R/ S V 0000

R+#) 1H D/)TN+

+: DS)H MEM#M SRH

S//&T ME(S' GR+M /M)+H//

+: DS)H /M)N+ ,TH)/ +G /./,T+T N+ +G /./S TK/N

S//&T /M)N+,/./TH)/, S#M( /NDDT/ -STDT/' N+ /./S

GR+M /M)P/./S

R+#) 1H /M)N+, /./TH)/

+: DS)H D/)TN+,MN SRH,ME SRH ,DGG/R/N&/ 1/T=//N ME ND MN SRH G+R TA/ D/)RTM/NTS

TAT A./ M+R/ TAN 2 /M)+H//S

S//&T D/)TN+, MN(S', ME(S', ME(S' - MN(S'

GR+M /M)+H//

R+#) 1H D/)TN+

A.N &+#NT(Q' V 2

+: DS)H /./TH)/ ND A+= MNH TM/S /&A /M)+H// AS TK/N /./

S//&T /./TH)/, /M)N+, &+#NT(Q'

GR+M /M)P/./S

R+#) 1H /./TH)/,/M)N+

;8

Page 185: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 185/238

+: DS)H /M)N+ +G TA/ /M)+H// =A+ AS TK/N M+R/ TAN 2 /./S N TA/ &#RR/NT M+NTA

S//&T /M)N+

GR+M /M)P/./S

=A/R/ T+P&AR(STDT/,IMMHHHHI' T+P&AR(SHSDT/,IMMHHHHI'

R+#) 1H /M)N+

A.N S#M(/NDDT/ -STDT/' V 2

+: DS)H D/SNT+N TAT &+NTN /TA/R M+R/ TAN ; /M)+H//S +R ./R/ SRH M+R/ TAN 2000

S//&T D/S

GR+M /M)+H//

R+#) 1H D/S

A.N &+#NT(Q' V ; +R .(S' V 2000

+: DS)H TA/ TH)/ +G /./ TAT S TK/N 1H M+R/ TAN 3 /M)+H//S

S//&T /./TH)/

GR+M /M)P/./S

R+#) 1H /./TH)/

A.N &+#NT (DSTN&T /M)N+' V 3

+: DS)H /M)N+,/M)NM/,DT/ +G +NN,D/)TNM/, SRH ND A+D

S//&T /M)N+, /M)NM/, D, D/)TNM/,S, A+D

GR+M /M)+H// /, D/)T D

=A/R/ /D/)TN+ DD/)TN+

+: DS)H /M)N+,STDT/,/NDDT/,/./NM/ G+R TA/ &+M)/T/D /./S

S//&T /M)N+, STDT/, /NDDT/, /./NM/

GR+M /M)P/./S /, /./S

=A/R/ //./TH)/ /./TH)/ ND /NDDT/ S N+T N#

+: DS)H D/)TN+,D/)TNM/,/M)NM/,H/RS +G /E)/R/N&/ G+R TA/ /M)+H//S =TA D/S I)R+I

S//&T /D/)TN+, D/)TNM/, /M)NM/, TR#N&(M+NTASP1/T=//N(SHSDT/,D' 4 2'

GR+M /M)+H// /, D/)T D

=A/R/ /D/)TN+ DD/)TN+ ND D/S I)R+I

+: DS)H /M)N+,/M)NM/,D/)TNM/,/./NM/,STDT/ ND ME N+ +G /./S N TA/ &T/+RH

S//&T //M)N+, /M)NM/, D/)TNM/, /./NM/,STDT/, N+/./S

GR+M /M)+H// /, D/)T D, /M)P/./S /, /./S

=A/R/ /D/)TN+ DD/)TN+ ND //./TH)/ /./TH)/

;8

Page 186: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 186/238

  ND //M)N+ //M)N+

+: DS)H TA/ D/TS +G /./S TK/N 1H /M)+H//S =A+ R/ A.N ID#K/I S TA/ A/D +G TA/

D/)RTM/NT

S//&T /Q

GR+M /M)P/./S /, /M)+H// /,D/)T D

=A/R/ //M)N+ //M)N+

ND /D/)TN+ DD/)TN+ ND A+D ID#K/I

+: DS)H TA/ D/TS +G /M)+H//S =A+ A./ +N/D GT/R /M)+H// I=HI AS +N/D

S//&T /Q

GR+M /M)+H// /, /M)+H// /2

=A/R/ /2/M)NM/ I=HI

ND /D V /2D

+: S//&T TA/ /M)+H//S =A+ A./ TK/N /./ N TA/ )R/S/NT M+NTA

S//&T Q GR+M /M)+H//

=A/R/ /M)N+ N

  ( S//&T /M)N+ GR+M /M)P/./S

=A/R/ T+P&AR(SHSDT/,IMMHHHHI' T+P&AR(STDT/,IMMHHHHI'

  '

+: DS)H TA/ D/TS +G D/)RTM/NTS =A&A A./ M+R/ TAN 2 /M)+H//S

S//&T Q GR+M D/)T

=A/R/ D/)TN+ N

( S//&T D/)TN+

  GR+M /M)+H//

  R+#) 1H D/)TN+

  A.N &+#NT(Q' V 2'

+: DSH TA/ D/TS +G /M)+H//S =A+ A./ TK/N M+R/ TAN 0 /./S

S//&T Q GR+M /M)+H//

=A/R/ /M)N+ N

  ( S//&T /M)N+

  GR+M /M)P/./S

R+#) 1H /M)N+

  A.N S#M( /NDDT/ - STDT/' V 0

'

;8

Page 187: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 187/238

+: DS)H TA/ D/TS +G D/)RTM/NTS =A&A A./ M+R/ TAN 3 /M)+H//S +N/D N TA/ &#RR/NT H/R 

S//&T Q GR+M D/)T

=A/R/ D/)TN+ N

  ( S//&T D/)TN+

  GR+M /M)+H//

  =A/R/ T+P&AR(D,IHHHHI' T+P&AR(SHSDT/,IHHHHI'

  R+#) 1H D/)TN+

  A.N &+#NT(Q' V 3

'

+: DS)H TA/ NM/ +G TA/ /M)+H// DR=N TA/ ME SRH

S//&T /M)NM/ GR+M /M)+H//

=A/R/ S

( S//&T ME(S'

  GR+M /M)+H//

  '

+: DS)H TA/ D/TS +G /M)+H//S =A+ AS TK/N M+R/ TAN 0 S&K/./S +R M+R/ TAN ; /./S

S//&T Q GR+M /M)+H//

=A/R/ /M)N+ N

  ( S//&T /M)N+

GR+M /M)P/./S

  =A/R/ /./TH)/ISI

  R+#) 1H /M)N+

  A.N S#M(/NDDT/ - STDT/ ' V 0

  '

  +R /M)N+ N

  ( S//&T /M)N+

GR+M /M)P/./S

  R+#) 1H /M)N+

  A.N S#M(/NDDT/ - STDT/ ' V ;

  '

;8

Page 188: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 188/238

+: DS)H /M)N+,/M)NM/,D/SNT+N ND D/)TNM/ +G /M)+H//S =A+ A./ N+T TK/N NH /./S N

TA/ &#RR/NT H/R 

S//&T /M)N+,/M)NM/,D/S,D/)TNM/

GR+M /M)+H// /, D/)T D

=A/R/ /D/)TN+ DD/)TN+

  ND /M)N+ N+T N

( S//&T /M)N+

GR+M /M)P/./S

  =A/R/ T+P&AR(STDT/,IHHHHI' T+P&AR(SHSDT/,IHHHHI'

  '

+: DS)H TA/ D/TS +G A+DIS

S//&T Q GR+M /M)+H//

=A/R/ /M)NM/ N

  ( S//&T A+D

  GR+M D/)T

  '

+: DS)H TA/ D/)RTM/NTS N =A&A /M)+H//S A./ TK/N ME N+ +G /./S

S//&T Q GR+M D/)T

=A/R/ D/)TN+ N

(

  S//&T D/)TN+

  GR+M /M)P/./S /, /M)+H// /

  =A/R/ //M)N+ //M)N+

 R+#) 1H D/)TN+

  A.N S#M(/NDDT/-STDT/'

  (

S//&T ME(S#M(/NDDT/-STDT/''

  GR+M /M)P/./S /, /M)+H// /

  =A/R/ //M)N+ //M)N+

  R+#) 1H D/)TN+

  '

 '

;8

Page 189: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 189/238

+: DS)H /M)N+,N++G/./S G+R /M)+H//S =A+ R/ A/D/D 1H IST/./I

S//&T /M)N+, S#M(/NDDT/-STDT/'

GR+M /M)P/./S

=A/R/ /M)N+ N

(

 S//&T /M)N+ GR+M /M)+H//

 =A/R/ D/)TN+ N

  (

  S//&T D/)TN+

  GR+M D/)T

  =A/R/ A+D IST/./I

  '

'

R+#) 1H /M)N+

+: DS)H D/TS +G /M)+H//S DR=N T+) 2 AA/ST SR/S

S//&T Q GR+M /M)+H// /

  =A/R/ 2 V ( S//&T &+#NT(Q'

  GR+M /M)+H//

  =A/R/ S V /S'

+: DR+) N #N=NT/D &+#MN GR+M NH T1/

TAS S D+N/ N TAR// ST/)S

&R/T/ T1/ N/=T1/ S S//&T ,1,& GR+M +DT1/

2 DR+) T1/ +DT1/

3 R/NM/ N/=T1/ T+ +DT1/

+: DS)H D/TS +G D/)RTM/NT N =A&A T/ST +N/ /M)+H// AS TK/N M+R/ N+ +G /./S TAN./R/ /./S +G TA/ /M)+H//S =A+ +N/D N TA/ &#RR/NT H/R 

S//&T Q GR+M D/)T

=A/R/ D/)TN+ N

( S//&T D/)TN+

  GR+M /M)+H//

  =A/R/ /M)N+ N

  (

  S//&T /M)N+

;8

Page 190: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 190/238

  GR+M /M)P/./S

  R+#) 1H /M)N+

  A.N S#M(/NDDT/ - STDT/' V

  (

S//&T .(/NDDT/ - STDT/'

  GR+M /M)P/./S

  =A/R/ T+P&AR(SHSDT/,IHHHHI' T+P&AR(STDT/,IHHHHI'

  '

  '

  '

+: A+= MNH /M)+H//S R/ /RNN M+R/ TAN TA/ ./R/ SRH +G MN/RS

S//&T &+#NT(Q'

GR+M /M)+H//

=A/R/ S V ( S//&T .(S'

  GR+M /M)+H//

  =A/R/ D/S IMN/RI'

+: DS)H TA/ D/TS +G /M)+H//S =A+ 1/+N T+ D/)RTM/NT +R 3 ND DR= M+R/ TAN ;000 SRH

S//&T Q GR+M /M)+H//

=A/R/ D/)TN+ N (,3' ND S V ;000

+: DS)H TA/ D/TS +G /./S =A/R/ TA/ /M)N+ S N TA/ RN/ 03 T+ 0

S//&T Q GR+M /M)P/./S

=A/R/ /M)N+ 1/T=//N 03 ND 0

+: DS)H D/TS +G /M)+H//S =A/R/ TA/ NM/ &+NTNS /TT/R E +R O

S//&T Q GR+M /M)+H//S

=A/R/ NM/ K/ I_E_I +R NM/ K/ I_O_I

+: DS)H D/TS +G D/)RTM/NT =A/R/ A/D +G D/)RTM/NT S IST/./I ND TA/ D/)TNM/ &+NTNS I)I S

TA/ ST &AR&T/R

S//&T Q GR+M D/)T

=A/R/ A+D IST/./I ND D/)TNM/ K/ I_)I

+: DS)H &+NSTRNTS +G /M)P/./S T1/

S//&T Q GR+M #S/RP&+NSTRNTS

=A/R/ T1/PNM/ I/M)P/./SI

;

Page 191: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 191/238

+: DS)H /M)N+,/M)NM/,DT/ +G +NN 5 /E)/R/N&/ N M+NTAS

S//&T /M)N+, /M)NM/, D, M+NTASP1/T=//N(SHSDT/,D' N+ M+NTAS

GR+M /M)+H//

+: DS)H /M)N+,/./TH)/,STDT/,N+ +G DHS 1/T=//N SHSDT/ 5 STDT/ G+R /./S TAT R/ N+T

&+M)/T/D

S//&T /M)N+, /./TH)/, STDT/, /NDDT/ - STDT/

GR+M /M)P/./S

=A/R/ /NDDT/ S N#

+: DS)H /M)N+,/M)NM/,DT/ +N =A&A /M)+H// T++K GRST SRH (SS#MN +N ST +G /&A M+NTA

SRH S )D'

S//&T /M)N+, /M)NM/, STPDH(D' C GRST S DT/

GR+M /M)+H//

+: DS)H TA/ D/TS +G /M)+H//S =A+ A./ TA/ )TT/RN IT/I N NM/ ND NM/ AS M+R/ TAN ; /TT/RS

S//&T Q GR+M /M)+H//

=A/R/ /M)NM/ K/ I_T/_I ND /NTA(/M)NM/' V ;

+: DS)H TA/ D/TS +G /./S +N =TA TA/ DT/ +G &+MN ST#RDH GT/R STDT/ ND N+ +G DHS +G

/./S G+R /./S TAT R/ &+M)/T/D

S//&T /M)N+, /./TH)/,STDT/, N/ETPDH(STDT/,ISaturda%I', /NDDT/ - STDT/

GR+M /M)P/./S

=A/R/ /NDT/ S N+T N#

+: DS)H TA/ D/TS +G /M)+H//S =A+ A./ +N/D N TA/ &#RR/NT H/R 

S//&T Q GR+M /M)+H//

=A/R/ T+P&AR(D,IHHHHI' T+P&AR(SHSDT/,IHHHHI'

+: DS)H TA/ D/TS +G /M)+H//S =A+S/ NM/ &+NTNS I))I N :TA,;TA,6TA )+ST+NS

S//&T Q GR+M /M)+H//

=A/R/ NSTR(/M)NM/,I))I' :

  +R 

S//&T Q GR+M /M)+H//

=A/R/ S#1STR(/M)NM/,:,3' I))I

+: DS)H /M)N+,NM/,A+DH =//K,=A&A D/)/NDS +N TA/ D/)T S G++=SB D/)TBM+NDH

D/)T2BTA#RSDH +TA/RSBS#NDH

S//&T /M)N+, /M)NM/,

;

Page 192: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 192/238

  D/&+D/(D/)TN+, ,IM+NDHI,2,ITA#RSDHI,IS#NDHI' A+DH

GR+M /M)+H//

+: DS)H TA/ /M)N+,/./TH)/,STDT/ N IDD-MMI G+RMT ND /NDN DT/ G+R TA/ /./S TAT R/

TK/N 1H /M)+H/S =TA N#M1/RS N TA/ RN/ 03-0< ND N TA/ &#RR/NT H/R

S//&T /M)N+, /./TH)/, T+P&AR(STDT/,IDD-MMI', /NDDT/

GR+M /M)P/./S

=A/R/ /M)N+ 1/T=//N 03 ND 0<

ND T+P&AR(SHSDT/,IHHHHI' T+P&AR(STDT/,IHHHHI'

 

+: TR#N&T/ TM/ )+RT+N N STRTN DT/ +G TA/ /./

#)DT/ /M)P/./S

  S/T STDT/ TR#N&(STDT/'

+: DS)H TA/ S#M +G SRH +G /&A D/)T

S//&T D/)TN+, S#M(S'

GR+M /M)+H//

R+#) 1H D/)TN+

+: DS)H TA/ ./R/ SRH +G /&A D/)T 1H TKN /M)+H//S =A+ A./ +N/D N TA/ &#RR/NT H/R

S//&T D/)TN+, .(S'

GR+M /M)+H//

=A/R/ T+P&AR(SHSDT/,IHHHHI' T+P&AR(D,IHHHHI'

R+#) 1H D/)TN+

+: DS)H /M)N+,T+T N++G /./S TK/N 1H /M)+H//

S//&T /M)N+, S#M(/NDDT/ - STDT/'

GR+M /M)P/./S

R+#) 1H /M)N+

+: DS)H TA/ T+T N+ +G /./S TK/N G+R /&A /./TH)/

S//&T /./TH)/, S#M(/NDDT/ - STDT/'

GR+M /M)P/./S

R+#) 1H /./TH)/

+: DS)H /M)N+ =A/R/ /M)+H// AS TK/N M+R/ TAN 0 /./S

S//&T /M)N+

GR+M /M)P/./S

R+#) 1H /M)N+

;

Page 193: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 193/238

A.N S#M(/NDDT/ - STDT/' V 0

+: DS)H TA/ H/R N =A&A M+R/ TAN ; /M)+H//S A./ +N/D

S//&T T+P&AR(D,IHHHHI'

GR+M /M)+H//

R+#) 1H T+P&AR(D,IHHHHI'

A.N &+#NT(Q' V ;

+: DS)H /M)N+ G+R /M)+H//S =A+ A./ TK/N M+R/ TAN 20 /./S N TA/ &#RR/NT H/R

S//&T /M)N+

GR+M /M)P/./S

=A/R/ T+P&AR(SHSDT/,IHHHHI' T+P&AR(STDT/,IHHHHI'

R+#) 1H /M)N+

A.N S#M(/NDDT/ - STDT/' V 20

+: DS)H TA/ /./TH)/ TAT AS 1//N TK/N G+R M+R/ TAN 0 TM/S

S//&T /./TH)/

GR+M /M)P/./S

R+#) 1H /./TH)/

A.N &+#NT(Q' V 0

+: DS)H D/)T,D/SNT+N,H/R 5 N+ +G /M)+H//S +N/D N TAT H/R N TAT D/)RTM/NT ND

D/SNT+N

S//&T D/)TN+, D/S, T+P&AR(D,IHHHHI', &+#NT(Q'

GR+M /M)+H//

R+#) 1H D/)TN+, D/S, T+P&AR(D,IHHHHI'

+: DS)H D/)T N =A&A TA/ ./R/ S +G NH SN/ D/SNT+N S M+R/ TAN 0000

S//&T DSTN&T D/)T

GR+M /M)+H/

R+#) 1H D/)T, D/S

A.N .(S' V 000

+: DS)H D/)TN+,DGG/R/N&/ 1/T=//N MN 5 ME +G SRH +G TA/ D/)T

S//&T D/)TN+, ME(S' - MN(S'

GR+M /M)+H//

R+#) 1H D/)TN+

;

Page 194: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 194/238

+: DS)H /./TH)/ G+R =A&A M+R/ TAN 0 /./S R/ TK/N N TA/ &#RR/NT M+NTA +R 20 /./S TK/N

S+ GR

S//&T /./TH)/

GR+M /M)P/./S=A/R/ T+P&AR(STDT/,IMMHHHHI' T+P&AR(SHSDT/,IMMHHHHI'

R+#) 1H /./TH)/A.N S#M(/NDDT/ - STDT/' V 0

#N+NS//&T /./TH)/

GR+M /M)P/./SR+#) 1H /./TH)/A.N S#M(/NDDT/ - STDT/' V 20

 

+: DS)H T+T N++G /./S +G /M)+H/S (&+NSD/RN SHSDT/ S /NDN DT/ G /NDN DT/ S N+T

.1/'

 S//&T S#M( N.(/NDDT/,SHSDT/' - STDT/'

GR+M /M)P/./S

 +: DS)H /M)N+,/./TH)/ ,STDT/,N+ +G /./S 5 ME N+ +G /./S G+R TAT &T/+RH

 S//&T /M)N+, //./TH)/,STDT/, /NDDT/ - STDT/, N+/./S

GR+M /M)P/./S /, /./S

=A/R/ //./TH)/ /./TH)/

+: DS)H D/)TN+,D/)TNM/,/M)NM/,D/SNT+N G+R TAT D/)T =A/R/ STRTN /TT/R S II

 S//&T /D/)TN+, D/)TNM/,/M)NM/,D/S

GR+M /M)+H// /, D/)T D

=A/R/ D/T)NM/ K/ I_I ND /D/)TN+ DD/)TN+

+: DS)H /M)N+,NM/,D/)TNM/,A+D G+R TA/ /M)+H//S =A+ A./ N+T TK/N NH /./ S+ GR

 S//&T /M)N+,/M)NM/, D/)TNM/,A+D

GR+M /M)+H// /, D/)T D

=A/R/ /M)N+ N+T N

  (S//&T /M)N+ GR+M /M)P/./S'

  ND /D/)TN+ DD/)TN+

+: DS)H /M)N+,NM/,D/)TNM/,/./NM/,STDT/,/NDDT/

 S//&T //M)N+,/M)NM/,D/)TNM/, /./NM/,STDT/,/NDDT/

GR+M /M)+H// /, D/)T D, /M)P/./S /

=A/R/ /D/)TN+ DD/)TN+ ND //M)N+ //M)N+

+: DS)H D/TS +G D/)T N =A&A T /ST +N/ /M)+H// AS +N/D N TA/ &#RR/NT M+NTA

 S//&T Q GR+M D/)T

=A/R/ D/)TN+ N

;

Page 195: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 195/238

  ( S//&T D/)TN+ GR+M /M)+H//

  =A/R/ T+P&AR(SHSDT/,IMMHHHHI' T+P&AR(D,IMMHHHHI' '

+: DS)H /./TH)/,/./NM/,/M)N+ ND STDT/ G+R TA/ /./S N&#DN /./TH)/S TAT A./

 N+T 1//N #S/D 1H NH /M)+H//

 S//&T /./TH)/,/./NM/, /M)N+ , STDT/

GR+M /M)P/./S /, /./S

=A/R/ /./TH)/ //./TH)/ (C'

 

+: DS)H TA/ D/TS +G /./S =A/R/ TA/ N++G DHS +G /./S S M+R/ TAN TA/ N++GDHS +G /./

TK/N 1H 0 N /./ TAT STRT/D +N ;-MR&A-00

 S//&T /Q

GR+M /M)P/./S /, /M)P/./S /2

=A/R/ /2STDT/ I0;-MR-2000I ND /2/M)N+ 0

  ND //NDDT/ - /STDT/ V /2/NDDT/ - /2STDT/

+: DS)H D/TS +G D/)T N =A&A TA/ ./R/ SRH S V 0000

 S//&T Q GR+M D/)T

=A/R/ D/)TN+ N

  ( S//&T D/)TN+

GR+M /M)+H//

  R+#) 1H D/)TN+

  A.N .(S' V 0000'

+: DS)H D/TS +G D/)T =A/R/ TA/ D/)T AS M+R/ TAN 3 /M)+H//S DR=N M+R/ TAN ;000

 S//&T Q GR+M D/)T

=A/R/ D/)TN+ N

  ( S//&T D/)TN+

GR+M /M)+H//

  =A/R/ S V ;000

  R+#) 1H D/)TN+

  A.N &+#NT(Q' V 3'

+: DS)H TA/ D/TS +G /M)+H//S =A+ AS N+T TK/N S&K /./ N &#RR/NT M+NTA

S//&T Q GR+M /M)+H//

=A/R/ /M)N+ N+T N

  ( S//&T /M)N+

;

Page 196: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 196/238

  GR+M /M)P/./S

  =A/R/ /./TH)/ ISI

  ND T+P&AR(STDT/,IMMHHHHI' T+P&AR(SHSDT/,IMMHHHHI'

  '

+: DS)H D/TS +G /M)+H//S DR=N TA/ MES

S//&T Q GR+M /M)+H//

=A/R/ S

(S//&T ME(S'

GR+M /M)+H//'

+: DS)H D/TS +G /M)+H//S DR=N M+R/ SRH TAN TA/ ./R/ S +G /M)+H//S +N/D N TA/&#RR/NT H/R

S//&T Q GR+M /M)+H//

=A/R/ S V

( S//&T .(S'

  GR+M /M)+H//

  =A/R/ T+P&AR(SHSDT/,IHHHHI' T+P&AR(D,IHHHHI'

  '

+: DS)H D/TS +G D/)TIS N =A&A N+ /M)+H// +N/D N TA/ &#RR/NT H/R

S//&T Q GR+M D/)T

=A/R/ D/)TN+ N+T N

( S//&T D/)TN+ GR+M /M)+H//

  =A/R/ T+P&AR(D,IHHHHI' T+P&AR(SHSDT/,IHHHHI'

  '

+: D//T/ D/TS +G /./S TK/N 1H /M)+H// =A+S/ /M)N+ S TA/ AA/ST /M)N+

D//T/ GR+M /M)P/./S

=A/R/ /M)N+ ( S//&T ME(/M)N+' GR+M /M)+H//'

+: DS)H TA/ D/TS +G /M)+H//S =A+ R/ 1/+NN T+ )R+D#&T+N D/)T ND A./ TK/N M+R/ TAN 20/./S S+ GR

S//&T /Q

GR+M /M)+H// /, D/)T D

;

Page 197: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 197/238

=A/R/ /D/)TN+ DD/)TN+ ND D/)TNM/ I)R+D#&T+NI

  ND /M)N+ N

( S//&T /M)N+

  GR+M /M)P/./S

  R+#) 1H /M)N+

  A.N S#M(/NDDT/-STDT/' V 20

  '

+: DS)H D/TS +G /./S =A/R/ TA/ /M)+H// S S M+R/ TAN 0000 ND +N/D N TA/ ST 6 M+NTAS

S//&T Q GR+M /M)P/./S

=A/R/ /M)N+ N

  ( S//&T /M)N+

GR+M /M)+H//

  =A/R/ S V 0000 ND M+NTASP1/T=//N(SHSDT/,D' U 6

  '

+: Displa% details "! empl"%ees draing t"p ; salaries

This is d"ne using c"rrelated su8uer% Su8uer% is used t" return

the numer "! empl"%ees h"se salar% is greater than the salar% "! the

current empl"%ee in main 8uer% ! that c"unt is less than ; that means

the empl"%ee is draing "ne "! the t"p !i$e salraies

select Q !r"m empl"%ee e

here ; V

( select c"unt(distinct sal'

  !r"m empl"%ee

  here sal V esal'

+: #)DT/ TA/ SRH +G /M)+H// 02 =TA TA/ ./R/ SRH +G AS D/)RTM/NT

#)DT/ /M)+H// / S/T S ( S//&T .(S' GR+M /M)+H// =A/R/ D/)TN+ /D/)TN+'

=A/R/ /M)N+ 02

+: DS)H D/TS +G D/)RTM/NT N =A&A TA/R/ R/ AA/ST N#M1/R +G /./S TK/N

S//&T Q GR+M D/)T

=A/R/ D/)TN+ N

(

  S//&T D/)TN+

GR+M /M)+H// /,/M)P/./S /

  =A/R/ //M)N+//M)N+

;

Page 198: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 198/238

 R+#) 1H D/)TN+

  A.N S#M(/NDDT/-STDT/'

( S//&T ME(S#M(/NDDT/ - STDT/''

  GR+M /M)+H// /, /M)P/./S /

  =A/R/ //M)N+ //M)N+

  R+#) 1H D/)TN+

  '

 '

+: R/NM/ &+#MN )J T+ JO()&TE +G /M)+H// T1/

R/NMN &+#MN D+N/ N TAR// ST/)S

&R/T/ N/= T1/ GR+M /M)+H// T1/ ./ S +NDT/ T+ D &+#MN N 7#/RH

2. #$%&'% '&% '%*+,-%% 

. &S S%%#' %*+/,0%*+/&*%0S&0 ,3/&'%0 %S40 %+'/,

5. 6$,* %*+,-%%;

; DR+) /M)+H// T1/

7. $,+ '&% %*+,-%%;

< R/NM/ N/= T1/ T+ /M)+H// T1/

8. $%/&*% '%*+,-%% ', %*+,-%%;

+: S=) TA/ SRH +G 0 =TA SRH +G 03

D/&R/

  SP03 /M)+H//S_TH)/

1/N

-- /T SRH +G 03

S//&T S NT+ SP03

 GR+M /M)+H//

=A/R/ /M)N+ 03

 -- #)DT/ SRH +G 03 =TA SRH +G 0

#)DT/ /M)+H//

S/T S (S//&T S GR+M /M)+H// =A/R/ /M)N+ 0'

  =A/R/ /M)N+ 03

-- #)DT/ SRH +G 0 =TA SRH +G 03

;

Page 199: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 199/238

#)DT/ /M)+H//

S/T S SP03

=A/R/ /M)N+ 0

COMMTI

/ND

+: &R/T/ )R+&/D#R/ T+ TK/ /M)N+ ND /./TH)/ ND NS/RT R+= NT+ /M)P/./S T1/ =TA TA/

G++=N &+NDT+NS

• &A/&K =A/TA/R /M)N+ ND /./TH)/ R/ .D

• &A/&K =A/TA/R /M)+H// S R/DH +N /./

• &A/&K =A/TA/R /M)+H// AS R/DH #S/D /./S N TAT TH)/

-- )R+&/D#R/ T+ NS/RT N/= R+= NT+ /M)P/./S T1/

-- TK/S /M)+H// N#M1/R ND /./TH)/

-- STDT/ +G /./ S SHSDT/ ND /NDDT/ S N#

&R/T/ +R R/)&/ )R+&/D#R/ N/=/./()/M)N+ N#M1/R, )T &AR'

S

STT#S N#M1/R('B0 -- NTO/ .R1/

&NT N#M1/R(3'

TN N#M1/R(2'

 N N#M1/R(2'

1/N

-- &A/&K =A/TA/R /M)+H// N+ S .D

S//&T 0 NT+ &NT

GR+M /M)+H//

=A/R/ /M)N+ )/M)N+

-- &A/&K =A/TA/R /./TH)/ S .D

-- G /./TH)/ S .D TA/N /T ME N+ +G /./S

-- N TAT /./TH)/

  STT#S B

S//&T N+/./S NT+ TN

  GR+M /./S

;

Page 200: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 200/238

Page 201: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 201/238

 

+: &R/T/ G#N&T+N T+ R/T#RN NM/S +G TA/ /M)+H//S DR=N A/ST SRH G TA/R/ S M+R/ TAN +N/M)+H//, /M)+H// NM/S R/ T+ 1/ S/)RT/D 1H &+MM

&R/T/ +R R/)&/ G#N&T+N /TAS/M)NM/S R/T#RN .R&AR2

S

  &#RS+R AS/M)P&#RS+R S

  S//&T /M)NM/ GR+M /M)+H// =A/R/ S (S//&T ME(S' GR+M /M)+H//'

  /NM/ .R&AR2(20'

  NM/S .R&AR2(200'

1/N

NM/S B II

  G+R R/& N AS/M)P&#RS+R

++)

  -- G N+T GRST NM/ TA/N DD &+MM

  G /NTA(NM/S' 0 TA/N

  NM/S B NM/S ^^ I,I

  /ND G

NM/S B NM/S ̂ ^ R/&/M)NM/

  /ND ++)

  R/T#RN NM/S

/ND

+: /T TA/ D/TS +G D/)T =A&A S A/D/D 1H )/RS+N =TA TA/ NM/ TAT &+NTNS /TT/R I&I ND II

S//&T Q GR+M D/)T

=A/R/ A+D K/ I_&__I

 

2<

Page 202: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 202/238

+: DS)H TA/ D/TS +G D/)TIS =A/R/ TA/ D/)TN+ S V0 ND D/)TNM/ /NDS =TA II

S//&T Q GR+M D/)T

=A/R/ D/)TN+ V 0 ND D/)TNM/ K/ I_I

 

+: DS)H D/TS +G /M)+H//S =A+ A./ M+R/ TAN 0000 SRH +R D/S ISI

S//&T Q GR+M /M)+H//

=A/R/ S V 0000 +R D/S ISI

 +: DS)H /M)N+,/M)NM/,SRH R+#ND/D T+ 00ISD+ ND N++G M+NTAS 1/T=//N T+DH ND DT/ +G

+NN

S//&T /M)N+, /M)NM/, R+#ND(S,-2' S , D, M+NTASP1/T=//N(SHSDT/,D' N+ M+NTAS

GR+M /M)+H//

 +: DS)H D/TS +G /./S TAT =/R/ TK/N N ST 20DHS

S//&T Q GR+M /M)P/./S

=A/R/ SHSDT/ -STDT/ U 20

 +: DS)H D/TS +G /./S N =A&A TA/ N++G DHS +G /./S S M+R/ TAN ;

 S//&T Q GR+M /M)P/./S

  =A/R/ /NDDT/ - STDT/ V ;

 +: DS)H S&K /./S 1H /M)N+ 0:

 S//&T Q GR+M /M)P/./S =A/R/ /M)N+ 0: ND /./TH)/ ISI

+: DS)H /M)N+,/./TH)/,N++G DHS +G /./ G+R /./S TAT =/R/ &+M)/T/D

S//&T /M)N+, /./TH)/, /NDDT/ - STDT/ N+ DHS

GR+M /M)P/./S

=A/R/ /NDDT/ S N+T N#

+: DS)H /M)+H// =A/R/ /M)NM/ &+NTNS /TT/RS IMI ND II N NH +RD/R

S//&T Q GR+M /M)+H//

=A/R/ /M)NM/ K/ I_M_I ND /M)NM/ K/ I__I

+: DS)H TA/ R+=S +G /M)+H// T1/ =A/R/ /M)+H// +N/D N TA/ ST 6 M+NTAS ND SV;000 NDD/S S N+T )R+RMM/R

S//&T Q GR+M /M)+H//

=A/R/ S V ;000 ND M+NTASP1/T=//N(SHSDT/,D' U 6 ND D/S UV I)R+I

+: DS)H D/TS +G /./S TAT =/R/ TK/N N TA/ &#RR/NT M+NTA

S//&T Q GR+M /M)P/./S

=A/R/ T+P&AR(STDT/,IMMHHI' T+P&AR(SHSDT/,IMMHHI'

2<

Page 203: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 203/238

+: DS)H /M)N+,GRST NM/,SRH ND /E)/R/N&/ N H/RS N TA/ &+M)NH

S//&T /M)N+, S#1STR(/M)NM/, ,D/&+D/(NSTR(/M)NM/,I I',0,/NTA(/M)NM/',NSTR(/M)NM/,I I'''

GRSTNM/, S, M+NTASP1/T=//N(SHSDT/,D' 4 2 /E)N H/RS

GR+M /M)+H//

+: DS)H TA/ D/TS +G /M)+H// =A+ +N/D N TA/ M+NTAS +G #H RR/S)/&T./ +G TA/ H/R

S//&T Q GR+M /M)+H//

=A/R/ T+P&AR(D,IMMI' <

+: DS)H D/TS +G /M)+H// =A+ A./ M+R/ TAN 0 &ARS N TA/ NM/ +R A.N /TT/R II ND I&I N

TA/ NM/

S//&T Q GR+M /M)+H//

=A/R/ /NTA(/M)NM/' V 0 ND /M)NM/ K/ I__&I

+: &AN/ TA/ NM/ +G /M)+H// 0; T+ #))/R&S/ ND R/M+./ /DN ND TRN S)&/S

#)DT/ /M)+H// S/T /M)NM/ #))/R(TRM(/M)NM/'' =A/R/ /M)N+ 0;

+: DS)H /M)N+,/./TH)/,TA/ M+NTA N =A&A /./ STRT/D ND TA/ M+NTA N =A&A /./ /ND/D G+R/./S =A/R/ TA/S/ T=+ M+NTAS R/ N+T SM/

S//&T /M)N+, /./TH)/, T+P&AR(STDT/,IM+NTAI', T+P&AR(/NDDT/,IM+NTAI'

GR+M /M)P/./S

=A/R/ T+P&AR(STDT/,IMMI' T+P&AR(/NDDT/,IMMI'

+: DS)H /./S TAT /ND/D N )R/.+#S M+NTA

S//&T Q GR+M /M)P/./S

=A/R/ T+P&AR(/NDDT/,IMMHHI' T+P&AR( DDPM+NTAS(SHSDT/,-', IMMHHI'

+: D//T/ D/TS +G /./S =A/R/ TA/ /./ STRT/D N TA/ GRST =//K +G TA/ )R/.+#S M+NTA

S//&T Q GR+M /M)P/./S

=A/R/ STDT/ 1/T=//N STPDH(DDPM+NTAS(SHSDT/,-2''C

ND STPDH(DDPM+NTAS(SHSDT/,-2'' C <

+: DS)H /M)NM/ N #))/R&S/,DH +G +NN ND DT/ +G GRST SRH ND =//K DH +G GRST SRH

S//&T #))/R(/M)NM/', D, STPDH(D' C , T+P&AR( STPDH(D' C , IDHI'

GR+M /M)+H//

+: DS)H M+NTAS N =A&A /M)+H//S +N/D N TA/ &#RR/NT H/R

S//&T DSTN&T T+P&AR(D,IM+NTAI' M+NTA

GR+M /M)+H//

=A/R/ T+P&AR(D,IHHHHI' T+P&AR(SHSDT/,IHHHHI'

+: DS)H .SRH +G TA/ /M)+H//S

S//&T .(S'

2<

Page 204: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 204/238

GR+M /M)+H//

+: DS)H /./TH)/,N++G TM/S /M)+H//S A./ TK/N TAT /./

S//&T /./TH)/, S#M(/NDDT/-STDT/'

GR+M /M)P/./S

R+#) 1H /./TH)/

+: DS)H D/)TN+,ND N++G /M)+H//S +N/D N TA/ &#RR/NT H/R

S//&T D/)TN+, &+#NT(Q'

GR+M /M)+H//

=A/R/ T+P&AR(D,IHHHHI' T+P&AR(SHSDT/,IHHHHI'

R+#) 1H D/)TN+

+: DS)H M+NTA NM/ ND A+= MNH /./S STRT/D N TAT M+NTA

S//&T T+P&AR(STDT/,IM+NTAI', &+#NT(Q'

GR+M /M)P/./S

R+#) 1H T+P&AR(STDT/,IM+NTAI'

+: DS)H TA/ /M)+H// =A+ A./ TK/N M+R/ TAN 0 /./S S+ GR

S//&T /M)N+

 GR+M /M)P/./S

 R+#) 1H /M)N+

 A.N S#M(/NDDT/-STDT/' V 0

+: DS)H TA/ /M)+H// =A+ AS TK/N M+R/ TAN ; S&K /./S N TA/ &#RR/NT H/R

S//&T /M)N+

GR+M /M)P/./S

=A/R/ T+P&AR(STDT/,IHHHHI' T+P&AR(SHSDT/,IHHHHI'

R+#) 1H /M)N+

A.N S#M(/NDDT/-STDT/' V ;

+: DS)H D/)TN+,D/S ND .SRH

S//&T D/)TN+, D/S, .(S'

GR+M /M)+H//

R+#) 1H D/)TN+, D/S

 

2<

Page 205: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 205/238

+: DS)H H/R,N++G /M)+H//S +N/D =TA D/S )R+RMM/R

S//&T T+P&AR(D,IHHHHI', &+#NT(Q'

GR+M /M)+H//

=A/R/ D/S I)R+I

R+#) 1H T+P&AR(D,IHHHHI'

+: DS)H /M)N+,/M)NM/,D/)TNM/ G+R /M)+H//S =A+ A./ +N/D N TA/ &#RR/NT M+NTA

S//&T /M)N+, /M)NM/, D/)TNM/

GR+M /M)+H// /, D/)T D

=A/R/ T+P&AR(D,IHHHHI' T+P&AR(SHSDT/,IHHHHI' ND /D/)TN+ DD/)TN+

+: DS)H /M)N+,/M)NM/,D/)TN+,D/)TNM/,/./NM/,STDT/ G+R /./S TAT R/ N+T &+M)/T/D

S//&T //M)N+,/M)NM/, /D/)TN+,D/)TNM/, /./NM/, STDT/

GR+M /M)+H// /, D/)T D, /./S , /M)P/./S /

=A/R/ /D/)TN+ DD/)TN+ ND //M)N+ //M)N+ ND /./TH)/ //./TH)/

+: DS)H /M)NM/ ND T+T N++G /./S TK/N(/M)NM/ AS T+ 1/ #N7#/'

S//&T /M)NM/, S#M(/NDDT/-STDT/'

GR+M /M)+H// /, /M)P/./S /

=A/R/ //M)N+ //M)N+

R+#) 1H /M)NM/

+: DS)H /M)N+,/M)NM/,/./TH)/,STDT/N&#D/ /M)+H//S =A+ A./ N+T TK/N NH /./ ND

DS)H TA/ DT/ N TA/ S&/NDN +RD/R +G /M)N+

S//&T //M)N+, /M)NM/, /./TH)/, STDT/

GR+M /M)+H// /, /M)P/./S /

=A/R/ //M)N+ //M)N+ (C'

+: DS)H TA/ /./S TAT =/R/ TK/N GT/R /M)N+ 06 T++K S&K /./(SS#MMN 06 AS TK/N

+NH +N/ S&K /./'

S//&T /Q

GR+M /M)P/./S /, /M)P/./S /2

=A/R/ /2/M)N+ 06 ND /2/./TH)/ ISI

  ND /STDT/ V /2STDT/

+: DS)H D/TS +G D/)T N =A&A =/ A./ N /M)+H// =TA TA/ NM/ &+NTNN IK/.NI

2<

Page 206: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 206/238

S//&T Q GR+M D/)T

=A/R/ D/)TN+ N ( S//&T D/)TN+

GR+M /M)+H// =A/R/ /M)NM/ K/ I_K/.N_I'

+: DS)H AA/ST T+T N++G /./S TK/N 1H SN/ /M)+H//

S//&T ME(S#M(/NDDT/-STDT/''

GR+M /M)P/./S

R+#) 1H /M)N+

+: DS)H AA/ST N++G DHS N SN/ /./

S//&T ME(/NDDT/-STDT/'

GR+M /M)P/./S

+: DS)H D/TS +G D/)T =A/R/ D/)TN+ AS M+R/ TAN ; /M)+H//S

S//&T Q GR+M D/)T

=A/R/ D/)TN+ N ( S//&T D/)TN+

  GR+M /M)+H//

R+#) 1H D/)TN+ A.N &+#NT(Q' V ;'

+: DS)H D/TS +G /M)+H// =A+ S DR=N TA/ MESRH

S//&T Q GR+M /M)+H//

=A/R/ S ( S//&T ME(S' GR+M /M)+H//'

+: DS)H D/TS +G /./S TAT =/R/ TK/N 1H /M)+H//S +G D/)T :

S//&T Q GR+M /M)P/./S

=A/R/ /M)N+ N ( S//&T /M)N+ GR+M /M)+H// =A/R/ D/)TN+ :'

+: DS)H D/)TN+ ND N++G /M)+H// =A+ A./ TK/N /./ N TA/ &#RR/NT M+NTA

S//&T D/)TN+, &+#NT(Q'

GR+M /M)+H//

=A/R/ /M)N+ N ( S//&T /M)N+ GR+M /M)P/./S

=A/R/ T+P&AR(STDT/,IMMHHI' T+P&AR(SHSDT/,IMMHHI'

  '

R+#) 1H D/)TN+

+: DS)H D/TS +G /M)+H//S =A+ A./ N+T TK/N NH /./ S+ GR

S//&T Q GR+M /M)+H//

=A/R/ /M)N+ N+T N ( S//&T /M)N+ GR+M /M)P/./S'

2<

Page 207: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 207/238

Page 208: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 208/238

+: DS)H D/TS +G /M)+H//S =A+ R/ A/D/D 1H 1 +R =A+ A./ TK/N /./ +N )R/.+#S

ITA#RSDHI

S//&T Q GR+M /M)+H//

=A/R/ D/)TN+ N (S//&T D/)TN+ GR+M D/)T =A/R/ A+D I1I'

  +R /M)N+ N( S//&T /M)N+

GR+M /M)P/./S

  =A/R/ TR#N&(STDT/' N/ETPDH(SHSDT/-;,IThursda%I''

+: DS)H TA/ D/TS +G /M)+H//S =TA GRST 2 AA/ST SRH

S//&T Q GR+M /M)+H// /

=A/R/ 2 V ( S//&T &+#NT(Q'

GR+M /M)+H// =A/R/ S V /S'

+: DS)H TA/ D/TS +G /./TH)/S =A/R/ TA/ /./ AS 1//N TK/N G+R M+R/ TAN ;0 TM/S

S//&T Q GR+M /./S

=A/R/ /./TH)/ N ( S//&T /./TH)/

  GR+M /M)P/./S

  R+#) 1H /./TH)/

  A.N &+#NT(Q' V ;0'

+: &AN/ TA/ D/)TN+ +G /M)+H// 0: T+ D/)TN+ +G INT/RN/TI D/)T

#)DT/ /M)+H// S/T D/)TN+ ( S//&T D/)TN+ GR+M D/)T =A/R/ D/)TNM/ INT/RN/TI'

=A/R/ /M)N+ 0:

+: DR+) &+#MN D/S GR+M /M)+H// T1/

ST/) B &R/T/ T1/ N/=/M) S S//&T /M)N+,/M)NM/,S,D/)TN+, D GR+M /M)+H//

ST/)2 B DR+) T1/ /M)+H//

ST/)3 B R/NM/ N/=/M) T+ /M)+H//

2<

Page 209: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 209/238

.T2,+ M#.+TANT $U,+,S

0 To find the nth row of a ta$le

S7V Select Q!r"m emp here r"id (select ma9(r"id' !r"m emp here r"num U :'

+r 

S7V Select Q!r"m emp here r"num U : minus select Q!r"m emp here r"num U 3

<0 To find d#2licate row"

S7V Select Q!r"m emp here r"id in (select ma9(r"id' !r"m emp gr"up % empn",ename, mgr, @", hiredate,

c"mm, deptn", sal'

+r 

S7V Select empn",ename,sal,@",hiredate,c"mm , c"unt(Q' !r"m emp gr"up % empn",ename,sal,@", hiredate,

c"mm ha$ing c"unt(Q' V

=0 To delete d#2licate row"

S7V Delete emp here r"id in (select ma9(r"id' !r"m emp gr"up % empn",ename,mgr,@", hiredate, sal, c"mm

deptn"'

>0 To find the co#nt of d#2licate row"

S7V Select ename, c"unt(Q' !r"m emp gr"up % ename ha$ing c"unt(Q' V

?0 How to di"2la alternati5e row" in a ta$le

S7V select Q!r"m emp here (r"id,0' in (select r"id,m"d(r"num,2' !r"m emp'

@0 6ettin- em2loee detail" of each de2artment who i" drawin- ma1im#m "al

S7V select Q!r"m emp here (deptn",sal' in ( select deptn",ma9(sal' !r"m emp gr"up % deptn"'

A0 How to -et n#m$er of em2loee" in each de2artment ' in which de2artment i" ha5in- more than <?DD

em2loee"

S7V Select deptn",c"unt(Q' !r"m emp gr"up % deptn" ha$ing c"unt(Q' V2;00

0 To re"et the time to the $e-innin- of the da

S7V Select t"Pchar(trunc(s%sdate',dd-m"n-%%%% hhBmiBss am' !r"m dual

0 To find nth ma1im#m "al

S7V Select Q!r"m emp here sal in (select ma9(sal' !r"m (select Q!r"m emp "rder % sal' here r"num U ;'

2<

Page 210: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 210/238

F%(CTO(S

Guncti"ns can e categ"riFed as !"ll"s

• Single r" !uncti"ns

• r"up !uncti"ns

S(6,E RO9 F%(CTO(S

Single r" !uncti"ns can e categ"riFed int" !i$e These ill e applied !"r each r" and

 pr"duces indi$idual "utput !"r each r"

 Numeric !uncti"ns• String !uncti"ns

• Date !uncti"ns

• Miscellane"us !uncti"ns

• &"n$ersi"n !uncti"ns

(%MERC F%(CTO(S

• s

• Sign

• S8rt

• M"d

•  N$l

• )"er 

• /9p

• n

• "g

• &eil

• Gl""r 

• R"und

• Trunk 

• 1itand

• reatest

• east

• &"alesce

a0 &BS

• s"lute $alue is the measure "! the magnitude "! $alue

• s"lute $alue is ala%s a p"siti$e numer

Snta1: as (value'E1:

S7V select as(;', as(-;', as(0', as(null' !r"m dual

1S(;' 1S(-;' 1S(0' 1S(N#'

---------- ---------- ---------- -------------

; -; 0

$0 S6(

Sign gi$es the sign "! a $alue

Snta1: sign (value'

E1:S7V select sign(;', sign(-;', sign(0', sign(null' !r"m dual

SN(;' SN(-;' SN(0' SN(N#'

---------- ---------- ---------- --------------

- 0

c0 S+RT

This ill gi$e the s8uare r""t "! the gi$en $alue

Snta1: s8rt (value' -- here $alue must e p"siti$e

2;

Page 211: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 211/238

E1:

S7V select s8rt(:', s8rt(0', s8rt(null', s8rt(' !r"m dual

S7RT(:' S7RT(0' S7RT(N#' S7RT('

---------- ------------- ----------------- ---------------

2 0

d0 MO)

This ill gi$e the remainder

Snta1: m"d (value0 divisor '

E1:

S7V select m"d(<,:', m"d(,;', m"d(null,null', m"d(0,0', m"d(-<,:' !r"m dual

M+D(<,:' M+D(,;' M+D(N#,N#' M+D(0,0' M+D(-<,:'

------------ ---------- --------------------- ----------- -- -----------

3 0 -3

e0 (!,

This ill sustitutes the speci!ied $alue in the place "! null $alues

Snta1: n$l (null_col0 replacement_value'

E1:

S7V select Q !r"m student -- here !"r 3rd r" marks $alue is null

 N+ NM/ MRKS

--- ------- ---------

a 00

2 200

3 c

S7V select n", name, n$l(marks,300' !r"m student

 N+ NM/ N.(MRKS,300'

--- ------- ---------------------

a 00

2 200

3 c 300

S7V select n$l(,2', n$l(2,3', n$l(:,3', n$l(;,:' !r"m dual

 N.(,2' N.(2,3' N.(:,3' N.(;,:'---------- ---------- ---------- ----------

2 : ;

S7V select n$l(0,0', n$l(,', n$l(null,null', n$l(:,:' !r"m dual

 N.(0,0' N.(,' N.(null,null' N.(:,:'

---------- ---------- ----------------- ----------

0 :

2;

Page 212: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 212/238

f0 PO9ER 

)"er is the ailit% t" raise a $alue t" a gi$en e9p"nent

Snta1: p"er (value0 exponent '

E1:

S7V select p"er(2,;', p"er(0,0', p"er(,', p"er(null,null', p"er(2,-;' !r"m dual

)+=/R(2,;' )+=/R(0,0' )+=/R(,' )+=/R(N#,N#' )+=/R(2,-;'

-------------- -------------- ----- --------- --------------- -------- ---------------32 032;

-0 E7P

This ill raise e $alue t" the gi$e p"er

Snta1: e9p (value'

E1:

S7V select e9p(', e9p(2', e9p(0', e9p(null', e9p(-2' !r"m dual

/E)(' /E)(2' /E)(0' /E)(N#' /E)(-2'

-------- --------- - ------- ------------- - ---------

2<>2>>3 <3>?0;6 3;33;2>3

h0 ,(

This is ased "n natural "r ase e l"garithm

Snta1: ln (value' -- here $alue must e greater than Fer" hich is p"siti$e "nl%

E1:

S7V select ln(', ln(2', ln(null' !r"m dual

N(' N(2' N(N#'

------- ------- ------------

0 6?3:<>

n and /9p are recipr"cal t" each "ther

/E) (3' 200>;;36?

N (200>;;36?' 3

i0 ,O6

This is ased "n 0 ased l"garithm

Snta1: l"g (0, value'-- here $alue must e greater than Fer" hich is p"siti$e "nl%

E1:

S7V select l"g(0,00', l"g(0,2', l"g(0,', l"g(0,null' !r"m dual

+(0,00' +(0,2' +(0,' +(0,N#'

--------------- ----------- ------------ -----------------

2 3002???6 0

N ($alue' + (/E)(', $alue'

S7V select ln(3', l"g(e9p(',3' !r"m dual

2;

Page 213: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 213/238

N(3' +(/E)(',3'

------- -----------------

0?>622? 0?>622?

 0 CE,

This ill pr"duce a h"le numer that is greater than "r e8ual t" the speci!ied $alue

Snta1: ceil (value'

E1:

S7V select ceil(;', ceil(;', ceil(-;', ceil( -;', ceil(0', ceil(null' !r"m dual

&/(;' &/(;' &/(-;' &/(-;' &/(0' &/(N#'

--------- ----------- ---------- ------------ -------- --------------

; 6 -; -; 0

k0 F,OOR This ill pr"duce a h"le numer that is less than "r e8ual t" the speci!ied $alue

Snta1: !l""r (value'

E1:

S7V select !l""r(;', !l""r(;', !l""r(-;', !l""r( -;', !l""r(0', !l""r(null' !r"m dual

G++R(;' G++R(;' G++R(-;' G++R(-;' G++R(0' G++R(N#'

----------- ------------- ------------ -------------- ----------- ----------------; ; -; -6 0

l0 RO%()

This ill r"unds numers t" a gi$en numer "! digits "! precisi"nSnta1: r"und (value0 precision'

E1:

S7V select r"und(2323:;', r"und(2323:;,2', r"und(2323;:,2' !r"m dual

R+#ND(2323:;' R+#ND(2323:;,0' R+#ND(2323:;,2' R+#ND(2323;:,2'

--------------------- ------------------------ ----------------------- -----------------------23 23 2323 232:

S7V select r"und(2323:;,-', r"und(2323:;,-2', r"und(2323:;,-3',

r"und(2323:;,-:' !r"m dualR+#ND(2323:;,-' R+#ND(2323:;,-2' R+#ND(2323:;,-3' R+#ND(2323:;,-:'

------------------------ ------------------------- ------------------------ ------------------------

20 00 0 0

S7V select r"und(23,0', r"und(23,', r"und(23,2' !r"m dual

R+#ND(23,0' R+#ND(23,' R+#ND(23,2'

----------------- ----------------- ----------------23 23 23

S7V select r"und(-23,0', r"und(-23,', r"und(-23,2' !r"m dual

R+#ND(-23,0' R+#ND(-23,' R+#ND(-23,2'

2;

Page 214: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 214/238

------------------ ----------------- -------------------

-23 -23 -23

S7V select r"und(23,-', r"und(23,-2', r"und(23,-3', r"und(-23,-', r"und(-23,-

2', r"und(-23,-3' !r"m dual

R+#ND(23,-' R+#ND(23,-2' R+#ND(23,-3' R+#ND(-23,-' R+#ND(-23,-2'R+#ND(-23,-3'

------------- ------------- ------------- -------------- -------------- --------------

20 00 0 -20 -00 0

S7V select r"und(null,null', r"und(0,0', r"und(,', r"und(-,-', r"und(-2,-2' !r"m

dual

R+#ND(N#,N#' R+#ND(0,0' R+#ND(,' R+#ND(-,-' R+#ND(-2,-2'----------------------- -------------- -------------- ---------------- ----------------

0 0 0

m0 TR%(C

This ill truncates "r ch"ps "!! digits "! precisi"n !r"m a numer

Snta1: trunc (value0 precision'

E1:

S7V select trunc(2323:;', trunc(2323:;,2', trunc(2323;:,2' !r"m dual

TR#N&(2323:;' TR#N&(2323:;,2' TR#N&(2323;:,2'

--------------------- ----------------------- -----------------------

23 2323 2323

S7V select trunc(2323:;,-', trunc(2323:;,-2', trunc(2323:;,-3',

trunc(2323:;,-:' !r"m dual

TR#N&(2323:;,-' TR#N&(2323:;,-2' TR#N&(2323:;,-3' TR#N&(2323:;,-:'

------------------------ ------------------------ ----------------------- ------------------------

20 00 0 0

S7V select trunc(23,0', trunc(23,', trunc(23,2' !r"m dual

TR#N&(23,0' TR#N&(23,' TR#N&(23,2'

---------------- ---------------- -----------------

23 23 23

S7V select trunc(-23,0', trunc(-23,', trunc(-23,2' !r"m dual

TR#N&(-23,0' TR#N&(-23,' TR#N&(-23,2'

----------------- ----------------- -----------------

-23 -23 -23

S7V select trunc(23,-', trunc(23,-2', trunc(23,-3', trunc(-23,-', trunc(-23,2',

trunc(-23,-3' !r"m dual

2;

Page 215: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 215/238

TR#N&(23,-' TR#N&(23,-2' TR#N&(23,-3' TR#N&(-23,-' TR#N&(-23,2' TR#N&(-

23,-3'

------------- ------------- ------------- -------------- ------------- --------------

20 00 0 -20 -23 0

S7V select trunc(null,null', trunc(0,0', trunc(,', trunc(-,-', trunc(-2,-2' !r"m dualTR#N&(N#,N#' TR#N&(0,0' TR#N&(,' TR#N&(-,-' TR#N&(-2,-2'

----------------------- ------------- ------------- --------------- ----------------

0 0 0

n0 BT&()

This ill per!"rm itise and "perati"n

Snta1: itand (value10 value2'

E1:

S7V select itand(2,3', itand(0,0', itand(,', itand(null,null', itand(-2,-3' !r"m

dual

1TND(2,3' 1TND(0,0' 1TND(,' 1TND(N#,N#' 1TND(-2,-3'

-------------- --------------- -------------- ------------------------ -----------------

2 0 -:

o0 6RE&TEST

This ill gi$e the greatest numer

Snta1: greatest (value10 value20 value 9 valuen'

E1:

S7V select greatest(, 2, 3', greatest(-, -2, -3' !r"m dual

R/T/ST(,2,3' R/T/ST(-,-2,-3'

-------------------- -----------------------

3 -

• ! all the $alues are Fer"s then it ill displa% Fer"

• ! all the parameters are nulls then it ill displa% n"thing

• ! an% "! the parameters is null it ill displa% n"thing

20 ,E&ST

This ill gi$e the least numer

2;

Page 216: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 216/238

Snta1: least (value10 value20 value 9 valuen'

E1:

S7V select least(, 2, 3', least(-, -2, -3' !r"m dual

/ST(,2,3' /ST(-,-2,-3'

-------------------- -----------------------

-3

• ! all the $alues are Fer"s then it ill displa% Fer"

• ! all the parameters are nulls then it ill displa% n"thing

• ! an% "! the parameters is null it ill displa% n"thing

;0 CO&,ESCE

This ill return !irst n"n-null $alue

Snta1: c"alesce (value10 value20 value 9 valuen'

E1:

S7V select c"alesce(,2,3', c"alesce(null,2,null,;' !r"m dual

&+/S&/(,2,3' &+/S&/(N#,2,N#,;'

------------------- -------------------------------

2

STR(6 F%(CTO(S

• nitcap

• #pper 

• "er 

• ength

2;

Page 217: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 217/238

• Rpad

• pad

• trim

• Rtrim

• Trim

•Translate

• Replace

• S"unde9

• &"ncat ( L ^^ L &"ncatenati"n "perat"r'

• scii

• &hr 

• Sustr 

• nstr 

• Dec"de

•reatest

• east

• &"alesce

a0 (TC&P

This ill capitaliFe the initial letter "! the string

Snta1: initcap ( strin! '

E1:

S7V select initcap(Ic"mputerI' !r"m dual

NT&)

-----------

&"mputer 

$0 %PPER 

This ill c"n$ert the string int" uppercase

Snta1: upper ( strin! '

E1:S7V select upper(Ic"mputerI' !r"m dual

#))/R 

-----------

&+M)#T/R 

c0 ,O9ER 

This ill c"n$ert the string int" l"ercase

Snta1: l"er ( strin! '

E1:S7V select l"er(I&+M)#T/RI' !r"m dual

+=/R 

-----------

c"mputer 

d0 ,E(6TH

This ill gi$e length "! the string

Snta1: length ( strin! '

2;

Page 218: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 218/238

E1:

S7V select length(Ic"mputerI' !r"m dual

/NTA

-----------

>

e0 RP&)This ill all"s %"u t" pad the right side "! a c"lumn ith an% set "! characters

Snta1: rpad ( strin!0 len!t :0 paddin!_car'

E1:

S7V select rpad(Ic"mputerI,;,IQI', rpad(Ic"mputerI,;,IQ`I' !r"m dual

R)D(I&+M)#T/RI R)D(I&+M)#T/RI

---------------------- ----------------------

c"mputerQQQQQQQ c"mputerQ`Q`Q`Q

-- De!ault padding character as lank space

f0 ,P&)

This ill all"s %"u t" pad the le!t side "! a c"lumn ith an% set "! characters

Snta1: lpad ( strin!0 len!t :0 paddin!_car'

E1:

S7V select lpad(Ic"mputerI,;,IQI', lpad(Ic"mputerI,;,IQ`I' !r"m dual

)D(I&+M)#T/RI )D(I&+M)#T/RI

--------------------- ---------------------

QQQQQQQc"mputer Q`Q`Q`Qc"mputer 

• De!ault padding character as lank space

-0 ,TRM

This ill trim "!! unanted characters !r"m the le!t end "! string

Snta1: ltrim ( strin! :0unwanted_cars'

E1:

S7V select ltrim(Ic"mputerI,Ic"I', ltrim(Ic"mputerI,Ic"mI' !r"m dual

TRM( TRM

-------- ---------

mputer puter 

S7V select ltrim(Ic"mputerI,IputerI', ltrim(Ic"mputerI,I"mputerI' !r"m dual

TRM(I& TRM(I&

---------- ----------

2;

Page 219: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 219/238

c"mputer c"mputer 

• ! %"u ha$ent speci!% an% unanted characters it ill displa% entire string

h0 RTRM

This ill trim "!! unanted characters !r"m the right end "! string

Snta1: rtrim ( strin! :0 unwanted_cars'

E1:

S7V select rtrim(Ic"mputerI,IerI', rtrim(Ic"mputerI,IterI' !r"m dual

RTRM( RTRM

-------- ---------

c"mput c"mpu

S7V select rtrim(Ic"mputerI,Ic"mput', rtrim(Ic"mputerI,Ic"mputeI' !r"m dual

RTRM(I& RTRM(I&

---------- ----------

c"mputer c"mputer 

• ! %"u ha$ent speci!% an% unanted characters it ill displa% entire string

i0 TRM

This ill trim "!! unanted characters !r"m the "th sides "! string

Snta1: trim (unwanted_cars !r"m strin! '

E1:

S7V select trim( IiI !r"m IindianiI' !r"m dual

TRM(

-----

ndian

S7V select trim( leadingIiI !r"m IindianiI' !r"m dual -- this ill "rk as TRM

TRM(

------

ndiani

S7V select trim( trailingIiI !r"m IindianiI' !r"m dual -- this ill "rk as RTRM

TRM(T

------

ndian

 0 TR&(S,&TE

This ill replace the set "! characters, character % character

Snta1: translate ( strin!0 old_cars0 new_cars'

E1:

2;

Page 220: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 220/238

S7V select translate(IindiaI,IinI,I9%I' !r"m dual

TRNS

--------

9%d9a

k0 REP,&CE

This ill replace the set "! characters, string % stringSnta1: replace ( strin!0 old_cars :0 new_cars'

E1:

S7V select replace(IindiaI,IinI,I9%I', replace(Lindia,in' !r"m dual

R/)&/ R/)&/

----------- -----------

E%dia dia

l0 SO%()E7

This ill e used t" !ind "rds that s"und like "ther "rds, e9clusi$el% used in here clause

Snta1: s"unde9 ( strin! '

E1:

S7V select Q !r"m emp here s"unde9(ename' s"unde9(ISMTI'

/M)N+ /NM/ +1 MR AR/DT/ S D/)TN+

-------- -------- ----- ----- ------------ --------- ----------

<36? SMTA &/RK <?02 <-D/&->0 ;00 20

m0 CO(C&T

This ill e used t" c"mine t" strings "nl%

Snta1: c"ncat ( strin!10 strin!2'

E1:

S7V select c"ncat(Ic"mputerI,I "perat"rI' !r"m dual

&+N&T(I&+M)#T/RI

-------------------------

c"mputer "perat"r 

• ! %"u ant t" c"mine m"re than t" strings %"u ha$e t" use c"ncatenati"n "perat"r (^^'

S7V select Ih"I ^^ I areI ^^ I %"uI !r"m dual

IA+=I^^IR/---------------

h" are %"u

n0 &SC

This ill return the decimal representati"n in the dataase character set "! the !irst character "! the string

Snta1: ascii ( strin! '

E1:

22

Page 221: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 221/238

S7V select ascii(IaI', ascii(IappleI' !r"m dual

S&(II' S&(I))/I'

------------ ------------------

?< ?<

o0 CHR 

This ill return the character ha$ing the inar% e8ui$alent t" the string in either the dataase character set "r

the nati"nal character set

Snta1: chr (number '

E1:

S7V select chr(?<' !r"m dual

&AR 

-----

a

20 S%BSTR 

This ill e used t" e9tract sustrings

Snta1: sustr ( strin!0 start_cr_count :0 no_of_cars'

E1:

S7V select sustr(Ic"mputerI,2', sustr(Ic"mputerI,2,;', sustr(Ic"mputerI,3,<' !r"m

dual

S#1STR( S#1ST S#1STR 

---------- ------- --------

"mputer "mput mputer 

• ! no_of_cars parameter is negati$e then it ill displa% n"thing

• ! "th parameters e9cept strin! are null "r Fer"s then it ill displa% n"thing

• ! no_of_cars parameter is greater than the length "! the string then it ign"res and calculates ased "n the

"rginal string length

• ! start_cr_count is negati$e then it ill e9tract the sustring !r"m right end

2 3 : ; 6 < >

& + M ) # T / R 

-> -< -6 -; -: -3 -2 -

;0 (STR 

This ill all"s %"u !"r searching thr"ugh a string !"r set "! characters

Snta1: instr ( strin!0 searc_str :0 start_cr_count :0 occurrence '

E1:

22

Page 222: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 222/238

S7V select instr(Iin!"rmati"nI,I"I,:,', instr(Iin!"rmati"nI,I"I,:,2' !r"m dual

NSTR(ING+RMT+NI,I+I,:,' NSTR(ING+RMT+NI,I+I,:,2'

------------------------------------ -------------------------------------

: 0

• ! %"u are n"t speci!%ing start_cr_count and occurrence then it ill start search !r"m the eginning and !ind

!irst "ccurrence "nl%

• ! "th parameters start_cr_count and occurrence are null, it ill displa% n"thing

r0 )ECO)E

• Dec"de ill act as $alue % $alue sustituti"n

• G"r e$er% $alue "! !ield, it ill checks !"r a match in a series "! i!4then tests

Snta1: dec"de (value0 if10 ten10 if20 ten20 99. else'

E1:

S7V select sal, dec"de(sal,;00,I"I,;000,IAighI,IMediumI' !r"m emp

S D/&+D/

----- ---------

;00 "

2;00 Medium

2000 Medium

3;00 Medium

3000 Medium

;000 Aigh

:000 Medium

;000 Aigh

>00 Medium

200 Medium

2000 Medium

2<00 Medium

2200 Medium

3200 Medium

S7V select dec"de(,,3', dec"de(,2,3,:,:,6' !r"m dual

D/&+D/(,,3' D/&+D/(,2,3,:,:,6'

----------------- ------------------------3 6

• ! the numer "! parameters are "dd and di!!erent then dec"de ill displa% n"thing

• ! the numer "! parameters are e$en and di!!erent then dec"de ill displa% last $alue

• ! all the parameters are null then dec"de ill displa% n"thing

• ! all the parameters are Fer"s then dec"de ill displa% Fer"

"0 6RE&TEST

22

Page 223: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 223/238

This ill gi$e the greatest string

Snta1: greatest ( strn!10 strin!20 strin! 9 strin!n'

E1:

S7V select greatest(IaI, II, IcI', greatest(IsatishI,IsrinuI,IsakethI' !r"m dual

R/T R/T

------- -------

c srinu

• ! all the parameters are nulls then it ill displa% n"thing

• ! an% "! the parameters is null it ill displa% n"thing

t0 ,E&ST

This ill gi$e the least string

Snta1: greatest ( strn!10 strin!20 strin! 9 strin!n'

E1:

S7V select least(IaI, II, IcI', least(IsatishI,IsrinuI,IsakethI' !r"m dual

/ST /ST

------- -------

a saketh

• ! all the parameters are nulls then it ill displa% n"thing

• ! an% "! the parameters is null it ill displa% n"thing

#0 CO&,ESCE

This ill gi$es the !irst n"n-null string

Snta1: c"alesce ( strn!10 strin!20 strin! 9 strin!n'

E1:

S7V select c"alesce(IaI,II,IcI', c"alesce(null,IaI,null,II' !r"m dual

&+/S&/ &+/S&/

----------- -----------

a a

)&TE F%(CTO(S

S%sdate

&urrentPdate

&urrentPtimestamp

S%stimestamp

"caltimestamp

DtimeF"ne

Sessi"ntimeF"ne

T"Pchar 

T"Pdate

ddPm"nths

M"nthsPeteen

 Ne9tPda%

22

Page 224: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 224/238

astPda%

/9tract

reatest

east

R"und

Trunc

 NePtime

&"alesce

+racle de!ault date !"rmat is DD-M+N-HH

=e can change the de!ault !"rmat t" "ur desired !"rmat % using the !"ll"ing c"mmand

S7V alter sessi"n set nlsPdateP!"rmat LDD-M+NTA-HHHH

1ut this ill e9pire "nce the sessi"n as cl"sed

a0 SS)&TE

This ill gi$e the current date and time

E1:

S7V select s%sdate !r"m dual

SHSDT/-----------

2:-D/&-06

$0 C%RRE(T)&TE

This ill returns the current date in the sessi"ns timeF"ne

E1:

S7V select currentPdate !r"m dual

&#RR/NTPDT/

------------------

2:-D/&-06

c0 C%RRE(TTMEST&MP

This ill returns the current timestamp ith the acti$e time F"ne in!"rmati"n

E1:

S7V select currentPtimestamp !r"m dual

&#RR/NTPTM/STM)

---------------------------------------------------------------------------2:-D/&-06 03:2:3>336? M C0;B30

d0 SSTMEST&MP

This ill returns the s%stem date, including !racti"nal sec"nds and time F"ne "! the dataase

E1:

S7V select s%stimestamp !r"m dual

SHSTM/STM)

---------------------------------------------------------------------------

22

Page 225: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 225/238

2:-D/&-06 03:?3>300?? M C0;B30

e0 ,OC&,TMEST&MP

This ill returns l"cal timestamp in the acti$e time F"ne in!"rmati"n, ith n" time F"ne in!"rmati"n sh"n

E1:

S7V select l"caltimestamp !r"m dual

+&TM/STM)

---------------------------------------------------------------------------

2:-D/&-06 03::>;02><: M

f0 )BTMEWO(E

This ill returns the current dataase time F"ne in #T& !"rmat (&""rdinated #ni$ersal Time'

E1:

S7V select dtimeF"ne !r"m dual

D1TM/O+N/

---------------

-0<B00

-0 SESSO(TMEWO(E

This ill returns the $alue "! the current sessi"ns time F"ne

E1:

S7V select sessi"ntimeF"ne !r"m dual

S/SS+NTM/O+N/

---------------------------------------------------------------------------

C0;B30

h0 TOCH&R 

This ill e used t" e9tract $ari"us date !"rmats

The a$ailale date !"rmats as !"ll"s

Snta1: t"Pchar (date, format '

)&TE FORM&TS

D -- N" "! da%s in eek  

DD -- N" "! da%s in m"nth

DDD -- N" "! da%s in %ear 

MM -- N" "! m"nth

M+N -- Three letter are$iati"n "! m"nth

M+NTA -- Gull% spelled "ut m"nth

RM -- R"man numeral m"nth

DH -- Three letter are$iated da%

22

Page 226: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 226/238

DH -- Gull% spelled "ut da%

H -- ast "ne digit "! the %ear 

HH -- ast t" digits "! the %ear 

HHH -- ast three digits "! the %ear 

HHHH -- Gull !"ur digit %ear 

SHHHH -- Signed %ear 

-- +ne digit %ear !r"m S+ standard

H -- T" digit %ear !r"m S+ standard

HH -- Three digit %ear !r"m S+ standard

HHH -- G"ur digit %ear !r"m S+ standard

H, HHH -- Hear ith c"mma

H/R -- Gull% spelled "ut %ear 

&& -- &entur%

7 -- N" "! 8uarters

= -- N" "! eeks in m"nth

== -- N" "! eeks in %ear 

= -- N" "! eeks in %ear !r"m S+ standard

AA -- A"urs

M -- MinutesSS -- Sec"nds

GG -- Gracti"nal sec"nds

M "r )M -- Displa%s M "r )M depending up"n time "! da%

M "r )M -- Displa%s M "r )M depending up"n time "! da%

D "r 1& -- Displa%s D "r 1& depending up"n the date

D "r 1& -- Displa%s D "r 1& depending up"n the date

GM -- )re!i9 t" m"nth "r da%, suppresses padding "! m"nth "r da%

TA -- Su!!i9 t" a numer 

S) -- su!!i9 t" a numer t" e spelled "ut

S)TA -- Su!!i9 c"minati"n "! TA and S) t" e "th spelled "ut

TAS) -- same as S)TA

E1:

S7V select t"Pchar(s%sdate,Idd m"nth %%%% hhBmiBss am d%I' !r"m dual

T+P&AR(SHSDT/,IDD M+NTA HHHHAABM

----------------------------------------------------

2: decemer 2006 02B03B23 pm sun

S7V select t"Pchar(s%sdate,Idd m"nth %earI' !r"m dual

T+P&AR(SHSDT/,IDDM+NTAH/RI'

-------------------------------------------------------

2: decemer t" th"usand si9

S7V select t"Pchar(s%sdate,Idd !mm"nth %earI' !r"m dual

T+P&AR(SHSDT/,IDD GMM+NTA H/RI'

-------------------------------------------------------

22

Page 227: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 227/238

2: decemer t" th"usand si9

S7V select t"Pchar(s%sdate,Iddth DDTAI' !r"m dual

T+P&AR(S

------------

2:th 2:TA

S7V select t"Pchar(s%sdate,Iddspth DDS)TAI' !r"m dual

T+P&AR(SHSDT/,IDDS)TADDS)TA

------------------------------------------

tent%-!"urth T=/NTH-G+#RTA

S7V select t"Pchar(s%sdate,Iddsp Ddsp DDS) I' !r"m dual

T+P&AR(SHSDT/,IDDS)DDS)DDS)I'

------------------------------------------------

tent%-!"ur Tent%-G"ur T=/NTH-G+#R 

i0 TO)&TE

This ill e used t" c"n$ert the string int" data !"rmat

Snta1: t"Pdate (date'

E1:

S7V select t"Pchar(t"Pdate(I2:4dec42006I,Idd4m"n4%%%%I', Idd Q m"nth Q da%I' !r"m dual

T+P&AR(T+PDT/(I2:4D/&420

--------------------------

2: Q decemer Q Sunda%

-- ! %"u are n"t using t"Pchar "racle ill displa% "utput in de!ault date !"rmat

 0 &))MO(THS

This ill add the speci!ied m"nths t" the gi$en dateSnta1: addPm"nths (date0 no_of_monts'

E1:

S7V select addPm"nths(t"Pdate(I-@an-??0I,Idd-m"n-%%%%I', ;' !r"m dual

DDPM+NTAS

----------------

-#N-?0

22

Page 228: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 228/238

S7V select addPm"nths(t"Pdate(I-@an-??0I,Idd-m"n-%%%%I', -;' !r"m dual

DDPM+NTA

---------------

-#->?

• ! no_of_monts is Fer" then it ill displa% the same date

• ! no_of_monts is null then it ill displa% n"thing

k0 MO(THSBET9EE(

This ill gi$e di!!erence "! m"nths eteen t" dates

Snta1: m"nthsPeteen (date10 date2'

E1:

S7V select m"nthsPeteen(t"Pdate(I-aug-??0I,Idd-m"n-%%%%I', t"Pdate(I-@an-??0I,Idd-m"n-%%%%I'' !r"m dual

M+NTASP1/T=//N(T+PDT/(I-#-??0I,IDD-M+N-HHHHI',T+PDT/(I-N-

??0I,IDD-M+N-HHHHI''

-----------------------------------------------------------------------------------------------

<

S7V select m"nthsPeteen(t"Pdate(I-@an-??0I,Idd-m"n-%%%%I', t"Pdate(I-aug-

??0I,Idd-m"n-%%%%I'' !r"m dual

M+NTASP1/T=//N(T+PDT/(I-N-??0I,IDD-M+N-HHHHI',T+PDT/(I-#-

??0I,IDD-M+N-HHHHI''

-------------------------------------------------------------------------------------------------

-<

l0 (E7T)&

This ill pr"duce ne9t da% "! the gi$en da% !r"m the speci!ied date

Snta1: ne9tPda% (date0 day'

E1B

S7V select ne9tPda%(t"Pdate(I2:-dec-2006I,Idd-m"n-%%%%I',IsunI' !r"m dual

 N/ETPDH(

-------------

3-D/&-06

-- ! the da% parameter is null then it ill displa% n"thing

22

Page 229: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 229/238

m0 ,&ST)&

This ill pr"duce last da% "! the gi$en date

Snta1: lastPda% (date'

E1:

S7V select lastPda%(t"Pdate(I2:-dec-2006I,Idd-m"n-%%%%I',IsunI' !r"m dual

STPDH(

-------------

3-D/&-06

n0 E7TR&CT

This is used t" e9tract a p"rti"n "! the date $alue

Snta1: e9tract ((%ear ^ m"nth ^ da% ^ h"ur ^ minute ^ sec"nd', date'

E1:

S7V select e9tract(%ear !r"m s%sdate' !r"m dual

/ETR&T(H/RGR+MSHSDT/'

------------------------------------2006

-- H"u can e9tract "nl% "ne $alue at a time

o0 6RE&TEST

This ill gi$e the greatest date

Snta1: greatest (date10 date20 date 9 daten'

E1:

S7V select greatest(t"Pdate(I-@an-?0I,Idd-m"n-%%I',t"Pdate(I-mar-?0I,Idd-m"n%%I',t"Pdate(I-apr-

?0I,Idd-m"n-%%I'' !r"m dual

R/T/ST(

-------------

-)R-?0

20 ,E&ST

This ill gi$e the least date

Snta1: least (date10 date20 date 9 daten'

E1:

S7V select least(t"Pdate(I-@an-?0I,Idd-m"n-%%I',t"Pdate(I-mar-?0I,Idd-m"n%%I', t"Pdate(I-apr-?0I,Idd-

m"n-%%I'' !r"m dual

/ST(

-------------

-N-?0

22

Page 230: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 230/238

;0 RO%()

R"und ill r"unds the date t" hich it as e8ual t" "r greater than the gi$en date

Snta1: r"und (date0 ( da% ^ m"nth ^ %ear  )'

! the sec"nd parameter as year then r"und ill checks the m"nth "! the gi$en date in the !"ll"ing range

N -- #N

# -- D/&

! the m"nth !alls eteen N and #N then it returns the !irst da% "! the current %ear

! the m"nth !alls eteen # and D/& then it returns the !irst da% "! the ne9t %ear

! the sec"nd parameter as mont then r"und ill checks the da% "! the gi$en date in the !"ll"ing ranges

-- ;

6 -- 3

! the da% !alls eteen and ; then it returns the !irst da% "! the current m"nth

! the da% !alls eteen 6 and 3 then it returns the !irst da% "! the ne9t m"nth

! the sec"nd parameter as day then r"und ill checks the eek da% "! the gi$en date in the !"ll"ing

ranges

S#N -- =/D

TA# -- S#N

! the eek da% !alls eteen S#N and =/D then it returns the pre$i"us sunda%

! the eekda% !alls eteen TA# and S#N then it returns the ne9t sunda%

• ! the sec"nd parameter as null then it returns n"thing

• ! the %"u are n"t speci!%ing the sec"nd parameter then r"und ill resets the time t" the egining "!

the current da% in case "! user speci!ied date

• ! the %"u are n"t speci!%ing the sec"nd parameter then r"und ill resets the time t" the egining "!

the ne9t da% in case "! s%sdate

E1:

S7V select r"und(t"Pdate(I2:-dec-0:I,Idd-m"n-%%I',I%earI', r"und(t"Pdate(I-mar- 06I,Idd-m"n-%%I',I%earI'

!r"m dual

R+#ND(T+P R+#ND(T+P ------------ ---------------

0-N-0; 0-N-06

S7V select r"und(t"Pdate(I-@an-0:I,Idd-m"n-%%I',Im"nthI', r"und(t"Pdate(I>-@an- 0:I,Idd-m"n-

%%I',Im"nthI' !r"m dual

R+#ND(T+P R+#ND(T+P 

------------- ---------------

23

Page 231: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 231/238

0-N-0: 0-G/1-0:

S7V select r"und(t"Pdate(I26-dec-06I,Idd-m"n-%%I',Ida%I', r"und(t"Pdate(I2?-dec-

06I,Idd-m"n-%%I',Ida%I' !r"m dual

R+#ND(T+P R+#ND(T+P 

-------------- --------------

2:-D/&-06 3-D/&-06

S7V select t"Pchar(r"und(t"Pdate(I2:-dec-06I,Idd-m"n-%%I'', Idd m"n %%%% hhBmiBss amI'!r"m dual

T+P&AR(R+#ND(T+PDT/(I

---------------------------------

2: dec 2006 2B00B00 am

r0 TR%(C

Trunc ill ch"ps "!! the date t" hich it as e8ual t" "r less than the gi$en date

Snta1: trunc (date0 ( da% ^ m"nth ^ %ear  )'

• ! the sec"nd parameter as year then it ala%s returns the !irst da% "! the current %ear

• ! the sec"nd parameter as mont then it ala%s returns the !irst da% "! the current m"nth

• ! the sec"nd parameter as day then it ala%s returns the pre$i"us sunda%

• ! the sec"nd parameter as null then it returns n"thing

• ! the %"u are n"t speci!%ing the sec"nd parameter then trunk ill resets the time t" the egining "!

the current da%

E1:

S7V select trunc(t"Pdate(I2:-dec-0:I,Idd-m"n-%%I',I%earI', trunc(t"Pdate(I-mar-06I,Idd-m"n-%%I',I%earI'

!r"m dual

TR#N&(T+P TR#N&(T+P 

------------- --------------

0-N-0: 0-N-06

S7V select trunc(t"Pdate(I-@an-0:I,Idd-m"n-%%I',Im"nthI', trunc(t"Pdate(I>-@an-0:I,Idd-m"n-%%I',Im"nthI

!r"m dual

TR#N&(T+P TR#N&(T+P 

23

Page 232: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 232/238

------------- -------------

0-N-0: 0-N-0:

S7V select trunc(t"Pdate(I26-dec-06I,Idd-m"n-%%I',Ida%I', trunc(t"Pdate(I2?-dec-06I,Iddm"n- %%I',Ida%I' !r"m

dual

TR#N&(T+P TR#N&(T+P 

------------- --------------

2:-D/&-06 2:-D/&-06

S7V select t"Pchar(trunc(t"Pdate(I2:-dec-06I,Idd-m"n-%%I'', Idd m"n %%%% hhBmiBss amI' !r"m dual

T+P&AR(TR#N&(T+PDT/(I

---------------------------------

2: dec 2006 2B00B00 am

"0 (E9TME

This ill gi$e the desired timeF"nes date and time

Snta1: nePtime (date0 current_time<one0 desired_time<one'

$ailale timeF"nes are as !"ll"s

TMEWO(ES

ST4DT -- tlantic standard4da% light time

1ST41DT -- 1ering standard4da% light time

&ST4&DT -- &entral standard4da% light time

/ST4/DT -- /astern standard4da% light time

MT -- reenich mean time

AST4ADT -- laska-Aaaii standard4da% light time

MST4MDT -- M"untain standard4da% light time

 NST -- Ne!"undland standard time

)ST4)DT -- )aci!ic standard4da% light time

HST4HDT -- Huk"n standard4da% light time

23

Page 233: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 233/238

E1:

S7V select t"Pchar(nePtime(s%sdate,IgmtI,I%stI',Idd m"n %%%% hhBmiBss amI' !r"m dual

T+P&AR(N/=PTM/(SHSDT

-----------------------------------

2: dec 2006 02B;B20 pm

S7V select t"Pchar(nePtime(s%sdate,IgmtI,IestI',Idd m"n %%%% hhBmiBss amI' !r"m dual

T+P&AR(N/=PTM/(SHSDT

-----------------------

2: dec 2006 06B;B26 pm

t0 CO&,ESCE

This ill gi$e the !irst n"n-null date

Snta1: c"alesce (date10 date20 date 9 daten'

E1:

S7V select c"alesce(I2-@an-?0I,I3-@an-??I', c"alesce(null,I2-@an-?0I,I23-mar-?>I,null'

!r"m dual

&+/S&/( &+/S&/(

------------- ------------2-@an-?0 2-@an-?0

MSCE,,&(EO%S F%(CTO(S

• #id

• #ser 

• .siFe

• Rank 

• DensePrank 

a0 %)

This ill returns the integer $alue c"rresp"nding t" the user currentl% l"gged in

E1:

23

Page 234: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 234/238

S7V select uid !r"m dual

#D

----------

3?

$0 %SER 

This ill returns the l"gins user name

E1:

S7V select user !r"m dual

#S/R 

----------------

SK/TA

c0 !SWE

This ill returns the numer "! %tes in the e9pressi"n

E1:

S7V select $siFe(23', $siFe(Ic"mputerI', $siFe(I2-@an-?0I' !r"m dual

.SO/(23' .SO/(I&+M)#T/RI' .SO/(I2-N-?0I'

------------- ----------------------- ----------------------3 > ?

d0 R&(8 

This ill gi$e the n"n-se8uential ranking

E1:

S7V select r"num,sal !r"m (select sal !r"m emp "rder % sal desc'

R+=N#M S

---------- ----------

;000

2 3000

3 3000

: 2?<;

; 2>;0

23

Page 235: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 235/238

6 2:;0

< 600

> ;00

? 300

0 2;0

2;0

2 00

3 000: ?;0

; >00

S7V select rank(2?<;' ithin gr"up("rder % sal desc' !r"m emp

RNK(2?<;'=TANR+#)(+RD/R1HSD/S&'

---------------------------------------------------------

:

d0 )E(SER&(8 

This ill gi$e the se8uential ranking

E1:

S7V select densePrank(2?<;' ithin gr"up("rder % sal desc' !r"m emp

D/NS/PRNK(2?<;'=TANR+#)(+RD/R1HSD/S&'

-----------------------------------------------------------------

3

CO(!ERSO( F%(CTO(S

• 1inPt"Pnum

• &hart"r"id

• R"idt"char 

• T"Pnumer 

• T"Pchar 

• T"Pdate

a0 B(TO(%M

This ill c"n$ert the inar% $alue t" its numerical e8ui$alent

Snta1: inPt"Pnum( binary_bits'

23

Page 236: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 236/238

E1:

S7V select inPt"Pnum(,,0' !r"m dual

1NPT+PN#M(,,0'

------------------------

6

! all the its are Fer" then it pr"duces Fer"• ! all the its are null then it pr"duces an err"r

$0 CH&RTORO9)

This ill c"n$ert a character string t" act like an internal "racle r" identi!ier "r r"id

c0 RO9)TOCH&R 

This ill c"n$ert an internal "racle r" identi!ier "r r"id t" character string

d0 TO(%MBER This ill c"n$ert a char "r $archar t" numer

e0 TOCH&R 

This ill c"n$ert a numer "r date t" character string

f0 TO)&TE

This ill c"n$ert a numer, char "r $archar t" a date

6RO%P F%(CTO(S

• Sum

• $g

• Ma9

• Min

• &"unt

r"up !uncti"ns ill e applied "n all the r"s ut pr"duces single "utput

a0 S%M

This ill gi$e the sum "! the $alues "! the speci!ied c"lumn

Snta1: sum (column'

23

Page 237: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 237/238

E1:

S7V select sum(sal' !r"m emp

S#M(S'

----------

3>600

$0 &!6

This ill gi$e the a$erage "! the $alues "! the speci!ied c"lumn

Snta1: a$g (column'

E1:

S7V select a$g(sal' !r"m emp

.(S'

---------------

2<;<:2>6

c0 M&7

This ill gi$e the ma9imum "! the $alues "! the speci!ied c"lumn

Snta1: ma9 (column'

E1:

S7V select ma9(sal' !r"m emp

ME(S'

----------

;000

d0 M(

This ill gi$e the minimum "! the $alues "! the speci!ied c"lumn

Snta1: min (column'

E1:

S7V select min(sal' !r"m empMN(S'

----------

;00

e0 CO%(T

This ill gi$e the c"unt "! the $alues "! the speci!ied c"lumn

23

Page 238: Dbms Lab Manual Regulation 2013

8/11/2019 Dbms Lab Manual Regulation 2013

http://slidepdf.com/reader/full/dbms-lab-manual-regulation-2013 238/238

Snta1: c"unt (column'

E1:

S7V select c"unt(sal',c"unt(Q' !r"m emp

&+#NT(S' &+#NT(Q'

-------------- ------------

: :