Anda di halaman 1dari 41

INTRODUCTION

1
STRUCTURED QUERY LANGUAGE(SQL)
SQL is standard language used to construct and access RDBMS of different kinds and
many hardware platforms. SQL provides commands for a variety of tasks including !
1. Querying the data
". #nserting$ %pdating and dropping o&'ects$
(. )reating$ replacing$ altering and dropping o&'ects$
*. )ontrolling access to the data&ase and its o&'ects$
+. ,uaranteeing data&ase consistency and integrity.
-he SQL statements are classified as follows
1. Data Definition Language(DDL)
create . #t is used to create a ta&le
alter . it is used to edit the physical structure of a ta&le. #t has two options$ add and
modify
drop . it is used to delete a ta&le.
Rename . it is used to rename a ta&le.
truncate . if there is no further use of records stroed in a ta&le and the structure has to &e
retained then the record alone can &e deleted.
2. Data Maniu!ation !anguage(DML)
insert ! insert command is used to insert data into an e/isting ta&le
select ! select command is used to retrieve data from ta&le in desired form
update . update statement is used to edit data in a ta&le
delete . delete statement is used to delete data from a ta&le
". T#an$a%tion Cont#o! Language
commit . this command is used to end a transaction. 0nly with the help of commit
command transaction changes can &e made permanent to the data&ase
roll&ack . roll&ack command is used to undo the work done in the current transaction.
1e can either roll&ack the entire transaction so that all changes made &y s2l statement are
undo or roll&ack a transaction to a savepoint.
Savepoint . savepoint are like markers to devide a very lengthy transaction to smaller
point. -hey are used to identify a transaction to which we can later roll&ack.
"
&. Data Cont#o! Language
grant . if a user create a ta&le there is no necessity for the user to &e given any privilege
to use it. Being it creates$ the user inherits authority over the ta&le.
Revoke . to withdraw the privilege that has &een granted to a user$ we use the revoke
command.
Sta#ting SQL
SQL3 prompt indicates that the SQL is ready to accept a command from the user.
1. CREATION O' DATA(ASE O()ECTS
TA(LES
-a&les are o&'ects which store the user data.
Syntax:
)reate ta&le 4ta&lename3
5columnname1 data type5si6e7 constraints$
columnname" data type5si6e7 constraints$
8888888888888888..
columnname n data type5si6e7 constraints
79
2. SQL COMMANDS
C#eate t*e fo!!o+ing Ta,!e$ -
1. supplier ta&le is used for storing the details of suppliers containing supplier code$
name$ status code and city.
". :art ta&le is used for storing the details of parts containing part code$ name$ color$
weight and location where the part is stored.
(. S: ta&le is used for storing the details of shipments containing supplier code$ part
code$ and the 2uantity shipped.
(
SQL. %#eate ta,!e $u!ie#
($%o/e 0a#%*a#2(1) #i2a#3 4e35
$na2e 0a#%*a#2(21) not nu!!5
$tatu$ nu2,e#(2) /efau!t 165
%it3 0a#%*a#2(21))7
-a&le created.
SQL. in$e#t into $u!ie# 0a!ue$(8S1858S2it*852658Lon/on8)7
1 row created.
SQL. in$e#t into $u!ie#($%o/e5$na2e5%it3) 0a!ue$(8S2858)one$8589a#i$8)7
1 row created.
SQL. in$e#t into $u!ie# 0a!ue$(8:$%o/e858:$na2e85:$tatu$58:%it38)7
;nter value for scode S(
;nter value for sname Blake
;nter value for status (<
;nter value for city :aris
old 1 insert into supplier values5=>scode=$=>sname=$>status$=>city=7
new 1 insert into supplier values5=s(=$=Blake=$(<$=:aris=7
1 row created.
SQL. ;
;nter value for scode S*
;nter value for sname )lark
;nter value for status "<
;nter value for city London
old 1 insert into supplier values5=>scode=$=>sname=$>status$=>city=7
new 1 insert into supplier values5=s*=$=)lark=$"< $=London=7
1 row created.
SQL. ;
;nter value for scode S+
;nter value for sname ?dams
;nter value for status (<
;nter value for city ?thens
old 1 insert into supplier values5=>scode=$=>sname=$>status$=>city=7
new 1 insert into supplier values5=s+=$=?dams=$(<$=?thens=7
1 row created.
*
SQL. $e!e%t < f#o2 $u!ie#7
S)0D; S@?M; S-?-%S )#-A
!!!!!!!!!!! !!!!!!!!!!!!!! !!!!!!!!!!!!! !!!!!!!!!!!
S1 Smith "< London
S" Bones 1< :aris
S( Blake (< :aris
S* )lark "< London
S+ ?dams (< ?thens
SQL. %#eate ta,!e a#t
(%o/e 0a#%*a#2(1) 9#i2a#3 4e35
na2e 0a#%*a#2(21) not nu!!5
%o!o# 0a#%*a#(=)5
+eig*t nu2,e#(152)5
%it3 0a#%*a#2(21))7
-a&le created.
SQL. insert into part values5=>pcode=$=>pname=$=>color=$>weight$=>city=79
;nter value for pcode :1
;nter value for pname @ut
;nter value for color Red
;nter value for weight 1"
;nter value for city London
old 1 insert into part values5=>pcode=$=>pname=$=>color=$>weight$=>city=7
new 1 insert into part values5=:1=$=@ut=$=Red=$1"$=London=7
1 row created.
SQL. ;
;nter value for pcode :"
;nter value for pname Bolt
;nter value for color ,reen
;nter value for weight 1C
;nter value for city :aris
old 1 insert into part values5=>pcode=$=>pname=$=>color=$>weight$=>city=7
new 1 insert into part values5=:"=$=Bolt=$=,reen=$1C$=:aris=7
1 row created.
SQL. ;
;nter value for pcode :(
;nter value for pname Screw
+
;nter value for color Blue
;nter value for weight 1C
;nter value for city Rome
old 1 insert into part values5=>pcode=$=>pname=$=>color=$>weight$=>city=7
new 1 insert into part values5=:(=$=Screw=$=Blue=$1C$=Rome=7
1 row created.
SQL. ;
;nter value for pcode :*
;nter value for pname Screw
;nter value for color Red
;nter value for weight 1*
;nter value for city London
old 1 insert into part values5=>pcode=$=>pname=$=>color=$>weight$=>city=7
new 1 insert into part values5=:*=$=Screw=$=Red=$1*$=London=7
1 row created.
SQL. ;
;nter value for pcode :+
;nter value for pname )am
;nter value for color Blue
;nter value for weight 1"
;nter value for city :aris
old 1 insert into part values5=>pcode=$=>pname=$=>color=$>weight$=>city=7
new 1 insert into part values5=:+=$=)am=$=Blue=$1"$=:aris=7
1 row created.
SQL. ;
;nter value for pcode :D
;nter value for pname )og
;nter value for color Red
;nter value for weight 1E
;nter value for city London
old 1 insert into part values5=>pcode=$=>pname=$=>color=$>weight$=>city=7
new 1 insert into part values5=:D=$=)og=$=Red=$1E$=London=7
1 row created.
D
SQL. $e!e%t < f#o2 9a#t7
:)0D; :@?M; )0L0R 1;#,F- )#-A
!!!!! !!!!!!!!!!!!!!!!!!!!!!!!! !!!!!! !!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!
:1 @ut Red 1" London
:" Bolt ,reen 1C :aris
:( Screw Blue 1C Rome
:* Screw Red 1* London
:+ )am Blue 1" :aris
:D )og Red 1E London
D rows selected.
SQL. %#eate ta,!e $
($%o/e 0a#%*a#2(1) #efe#en%e$ $u!ie#($%o/e)5
%o/e 0a#%*a#2(1) #efe#en%e$ a#t(%o/e)5
>t3 nu2,e#(152))7
-a&le created.
SQL. in$e#t into $ 0a!ue$(8:$%o/e858:%o/e85:>t3)7
;nter value for scode S1
;nter value for pcode :1
;nter value for 2ty (<<
old 1 insert into sp values5=>scode=$=>pcode=$>2ty7
new 1 insert into sp values5=S1=$=:1=$(<<7
1 row created.
SQL. ;
;nter value for scode S1
;nter value for pcode :"
;nter value for 2ty "<<
old 1 insert into sp values5=>scode=$=>pcode=$>2ty7
new 1 insert into sp values5=S1=$=:"=$"<<7
1 row created.
SQL. ;
;nter value for scode S1
;nter value for pcode :(
;nter value for 2ty *<<
old 1 insert into sp values5=>scode=$=>pcode=$>2ty7
new 1 insert into sp values5=S1=$=:(=$*<<7
C
1 row created.
SQL. ;
;nter value for scode S1
;nter value for pcode :*
;nter value for 2ty "<<
old 1 insert into sp values5=>scode=$=>pcode=$>2ty7
new 1 insert into sp values5=S1=$=:*=$"<<7
1 row created.
SQL. ;
;nter value for scode S1
;nter value for pcode :+
;nter value for 2ty 1<<
old 1 insert into sp values5=>scode=$=>pcode=$>2ty7
new 1 insert into sp values5=S1=$=:+=$1<<7
1 row created.
SQL. ;
;nter value for scode S1
;nter value for pcode :D
;nter value for 2ty 1<<
old 1 insert into sp values5=>scode=$=>pcode=$>2ty7
new 1 insert into sp values5=S1=$=:D=$1<<7
1 row created.
SQL. ;
;nter value for scode S"
;nter value for pcode :1
;nter value for 2ty (<<
old 1 insert into sp values5=>scode=$=>pcode=$>2ty7
new 1 insert into sp values5=S"=$=:1=$(<<7
1 row created.
SQL. ;
;nter value for scode S"
;nter value for pcode :"
;nter value for 2ty *<<
old 1 insert into sp values5=>scode=$=>pcode=$>2ty7
new 1 insert into sp values5=S"=$=:"=$*<<7
1 row created.
G
SQL. ;
;nter value for scode S(
;nter value for pcode :"
;nter value for 2ty "<<
old 1 insert into sp values5=>scode=$=>pcode=$>2ty7
new 1 insert into sp values5=S(=$=:"=$"<<7
1 row created.
SQL. ;
;nter value for scode S*
;nter value for pcode :"
;nter value for 2ty "<<
old 1 insert into sp values5=>scode=$=>pcode=$>2ty7
new 1 insert into sp values5=S*=$=:"=$"<<7
1 row created.
SQL. ;
;nter value for scode S*
;nter value for pcode :*
;nter value for 2ty (<<
old 1 insert into sp values5=>scode=$=>pcode=$>2ty7
new 1 insert into sp values5=S*=$=:*=$(<<7
1 row created.
SQL. ;
;nter value for scode S*
;nter value for pcode :+
;nter value for 2ty *<<
old 1 insert into sp values5=>scode=$=>pcode=$>2ty7
new 1 insert into sp values5=S*=$=:+=$*<<7
1 row created.
SQL. $e!e%t < f#o2 $7
S)0D; :)0D; Q-A
!!!!!!!!!! !!!!!!!!!! !!!!!!!!!!
S1 :1 (<<
S1 :" "<<
S1 :( *<<
S1 :* "<<
S1 :+ 1<<
E
S1 :D 1<<
S" :1 (<<
S" :" *<<
S( :" "<<
S* :" "<<
S* :* (<<
S* :+ *<<
1" rows selected.
2.1. Get a#tnu2,e#$ fo# a!! a#t$ $u!ie/ f#o2 S9.
SQL. $e!e%t %o/e f#o2 S97
:)0D;
!!!!!
:1
:"
:(
:*
:+
:D
:1
:"
:"
:"
:*
:+
2.2 Get uni>ue 9%o/e f#o2 S9.
SQL. $e!e%t uni>ue %o/e f#o2 S97
0R
SQL. $e!e%t /i$tin%t %o/e f#o2 S97
:)0D;
!!!!!
:1
:"
:(
:*
:+
:D
D rows selected.
1<
2.". Di$!a3 %it3 f#o2 Su!ie# u$ing /i$tin%t f#o2 Su!ie#
SQL. $e!e%t /i$tin%t %it3 f#o2 $u!ie#7
0R
SQL. $e!e%t uni>ue %it3 f#o2 $u!ie#7
)#-A
!!!!!!!!!!!!!!!!!!!!!!!!!
?thens
London
:aris
2.&. Di$!a3 na2e an/ %it3 f#o2 Su!ie# +*e#e $tatu$ ,et+een 16 an/ 16.
SQL. $e!e%t Sna2e5%it3 f#o2 $u!ie# +*e#e $tatu$ ,et+een 16 an/ 167
S@?M; )#-A
!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!
Smith London
Bones :aris
Blake :aris
)lark London
?dams ?thens
2.1. Di$!a3 na2e$ $ta#ting +it* ?(@ f#o2 Su!ie#.
SQL. $e!e%t $na2e f#o2 $u!ie# +*e#e $na2e !i4e 8(A87
S@?M;
!!!!!!!!!!!!!!!!!!!!!!!!!
Blake
2.=. Di$!a3 na2e$ en/ing +it* ?$@ f#o2 Su!ie#.
SQL. $e!e%t $na2e f#o2 $u!ie# +*e#e $na2e !i4e 8A$87
S@?M;
!!!!!!!!!!!!!!!!!!!!!!!!!
Bones
?dams
11
2.B. Di$!a3 a#t na2e$ *a0ing ?o@ a$ t*e $e%on/ %*a#a%te#.
SQL. $e!e%t 9na2e f#o2 a#t +*e#e na2e !i4e 8CoA87
:@?M;
!!!!!!!!!!!!!!!!!!!!!!!!!
Bolt
)og
2.D.Get $u!ie# nu2,e#$ an/ $tatu$ f#o2 $u!ie#$ +*o a#e !o%ate/ in ?9a#i$@.
SQL. $e!e%t $%o/e5$tatu$ f#o2 $u!ie# +*e#e %it3E89a#i$87
S)0D; S-?-%S
!!!!!!!!!!! !!!!!!!!!!
S" 1<
S( (<
2.F. Get $u!ie# nu2,e#$ fo# $u!ie#$ in 9a#i$ +it* $tatu$.26.
SQL. $e!e%t $%o/e f#o2 $u!ie# +*e#e %it3E89a#i$8 an/ $tatu$.267
S)0D;
!!!!!
S(
2.16. Get $u!ie# nu2,e#$ an/ $tatu$ fo# $u!ie#$ in 9a#i$ in /e$%en/ing o#/e# of
$tatu$.
SQL. $e!e%t $%o/e5$tatu$ f#o2 $u!ie# +*e#e %it3E89a#i$8 o#/e# ,3 $tatu$ /e$%7
S)0D; S-?-%S
!!!!!!!!!!! !!!!!!!!!!!!
S( (<
S" 1<
2.11. Li$t %o!o#$ %o22on to nut$ an/ $%#e+.
SQL. $e!e%t %o!o# f#o2 a#t +*e#e na2eE8Nut8 inte#$e%t $e!e%t %o!o# f#o2 a#t
+*e#e na2eE8S%#e+87
1"
)0L0R
!!!!!!
Red
2.12. Get a#t nu2,e#$ fo# a#t$ t*at eit*e# +eig* 2o#e 1D oun/$ o# a#e %u##ent!3
$u!ie/ ,3 $u!ie# S2 ( o# ,ot*)
SQL. $e!e%t %o/e f#o2 a#t +*e#e +eig*t.1D union $e!e%t %o/e f#o2 S9 +*e#e
$%o/eE8S287
:)0D;
!!!!!
:1
:"
:D
2.1". Get a#t nu2,e# an/ +eig*t < &1& (#et#ie0a! of %o2ute# 0a!ue$) f#o2 9a#t
SQL. $e!e%t %o/e5+eig*t<&1& f#o2 a#t7
:)0D; 1;#,F-H*+*
!!!!! !!!!!!!!!!
:1 +**G
:" CC1G
:( CC1G
:* D(+D
:+ +**G
:D GD"D
2.1&. Get t*e tota! nu2,e# of $u!ie#$ f#o2 Su!ie#
SQL. $e!e%t %ount(<) f#o2 $u!ie#7
)0%@-5H7
!!!!!!!!!!
+
2.11. Get t*e tota! >uantit3 of a#t 92 $u!ie/.
SQL. $e!e%t $u2(>t3) f#o2 S9 +*e#e %o/eE89287

1(
S%M5Q-A7
!!!!!!!!!!
1<<<
2.1=. 'o# ea%* a#t $u!ie/5 get t*e a#t nu2,e# an/ tota! >uantit3 $u!ie/ of t*at
a#t (u$e of g#ou ,3)
SQL. $e!e%t %o/e5$u2(>t3) f#o2 S9 g#ou ,3 %o/e7
:)0D; S%M5Q-A7
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!
:1 D<<
:" 1<<<
:( *<<
:* +<<
:+ +<<
:D 1<<
D rows selected.
2.1B. Get t*e enti#e $a#e *a0ing >uantit3 g#eate# t*an 266 ,ut ea%* of +*i%*5
$u!3 >uantit3 $*ou!/ ,e g#eate# t*an "66. Li$t t*e2 in /e$%en/ing o#/e# of t*e
a#t nu2,e#.
SQL. $e!e%t %o/e52aG(>t3) f#o2 $
+*e#e >t3.266
g#ou ,3 9%o/e
*a0ing $u2(>t3)."66
o#/e# ,3 %o/e /e$%7
:)0D; M?I5Q-A7
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!
:+ *<<
:( *<<
:" *<<
:1 (<<
2.1D. Get a#t nu2,e# an/ na2e$ of a!! %itie$ $u!3ing t*e a#t.
SQL. $e!e%t uni>ue %o/e5%it3 f#o2 $5$u!ie# +*e#e $.$%o/eE$u!ie#.$%o/e7
1*
:)0D; )#-A
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!
:1 London
:1 :aris
:" London
:" :aris
:( London
:* London
:+ London
:D London
G rows selected.
2.1F. Get $u!ie# na2e fo# $u!ie# +*o $u!3 a#t 92 u$ing ANY.
SQL. $e!e%t $na2e f#o2 $u!ie# +*e#e $%o/eEan3($e!e%t $%o/e f#o2 $ +*e#e
%o/eE8928)7
S@?M;
!!!!!!!!!!!!!!!!!!!!!!!!!
Smith
Bones
Blake
)lark
2.26. Get $u!ie# na2e fo# $u!ie# +*o $u!3 a#t 92 u$ing IN.
SQL. $e!e%t $na2e f#o2 $u!ie# +*e#e $%o/e in($e!e%t $%o/e f#o2 $ +*e#e
%o/eE8928)7
S@?M;
!!!!!!!!!!!!!!!!!!!!!!!!!
Smith
Bones
Blake
)lark
2.21. Get $u!ie# na2e$ fo# $u!ie#$ +*o $u!3 at !ea$t one #e/ a#t.
SQL. $e!e%t $na2e f#o2 $u!ie# +*e#e $%o/e in($e!e%t $%o/e f#o2 $ +*e#e %o/e
in($e!e%t %o/e f#o2 a#t +*e#e %o!o#E8Re/8))7
1+
S@?M;
!!!!!!!!!!!!!!!!!!!!!!!!!
Smith
Bones
)lark
2.22. Get $u!ie# na2e$ fo# $u!ie#$ +*o $u!3 a#t 92.
SQL. $e!e%t $na2e f#o2 $u!ie# +*e#e 8928 in ($e!e%t %o/e f#o2 $ +*e#e
$%o/eE$u!ie#.$%o/e)7
S@?M;
!!!!!!!!!!!!!!!!!!!!!!!!!
Smith
Bones
Blake
)lark
2.2". Get $u!ie# na2e$ fo# $u!ie#$ +*o $u!3 a#t 92 u$ing EHISTS.
SQL. $e!e%t $na2e f#o2 $u!ie# +*e#e eGi$t$($e!e%t < f#o2 $ +*e#e
$%o/eE$u!ie#.$%o/e an/ %o/eE8928)7
S@?M;
!!!!!!!!!!!!!!!!!!!!!!!!!
Smith
Bones
Blake
)lark
2.2&. Get $u!ie# na2e$ fo# $u!ie#$ +*o /o not $u!3 a#t 92 (not eGi$t$)
SQL. $e!e%t $na2e f#o2 $u!ie# +*e#e not eGi$t$($e!e%t < f#o2 $ +*e#e
$%o/eE$u!ie#.$%o/e an/ %o
/e E8928)7
S@?M;
!!!!!!!!!!!!!!!!!!!!!!!!!
?dams
1D
2.21. Get $u!ie# nu2,e#$ fo# $u!ie#$ +it* $tatu$ 0a!ue !e$$ t*an %u##ent
2aGi2u2 $tatu$ 0a!ue in t*e Su!ie# ta,!e.
SQL. $e!e%t $%o/e f#o2 $u!ie# +*e#e $tatu$I($e!e%t 2aG($tatu$) f#o2 $u!ie#)7
S)0D;
!!!!!
S1
S"
S*
2.2= Dou,!e t*e $tatu$ of a!! $u!ie#$ in Lon/on.
SQL. u/ate $u!ie# $et $tatu$ E2<$tatu$ +*e#e %it3E8Lon/on87
" rows updated.
2.2B. Set t*e >uantit3 to Je#o fo# a!! $u!ie#$ in Lon/on.
SQL. u/ate $ $et >t3E6 +*e#e8!on/on8E($e!e%t %it3 f#o2 $u!ie# +*e#e
$%o/eE$.$%o/e)7
E rows updated.
2.2D. Li$t t*e tota! +eig*t5 2ini2u2 +eig*t an/ a0e#age +eig*t of a#t$ %o!o# +i$e
an/ /i$!a3 on!3 t*o$e #o+$ *a0ing a0e#age +eig*t g#eate# t*an 12.
SQL. $e!e%t %o!o#5$u2(+eig*t)52in(+eig*t)5a0g(+eig*t) f#o2 a#t +*e#e
na2eE8nut8 o# na2e E8$%#e+8
g#ou ,3 %o!o# *a0ing a0g(+eig*t).127
)0L0R S%M51;#,F-7 M#@51;#,F-7 ?J,51;#,F-7
!!!!!! !!!!!!!!!!! !!!!!!!!!!! !!!!!!!!!!!
&lue 1C 1C 1C
red "D 1" 1(
2.2F. Li$t t*e $u!ie# nu2,e#$5 na2e$5 a#t nu2,e#$ an/ >uantit3.
SQL. $e!e%t $.$%o/e5$na2e5%o/e5>t3 f#o2 $u!ie#5$ +*e#e
$.$%o/eE$u!ie#.$%o/e7
1C
SK S@?M; :K Q-A
!! !!!!!!!!!! !!!!! !!!!!!!!!
S1 Smith :1 <
S1 Smith :" <
S1 Smith :( <
S1 Smith :* <
S1 Smith :+ <
S1 Smith :D <
S" Bones :1 (<<
S" Bones :" *<<
S( Blake :" "<<
S* )lark :" <
S* )lark :* <
S* )lark :+ <
2."6. Li$t t*e a#t$ uni>ue to $u!ie# S1.
SQL. $e!e%t %o/e f#o2 $ +*e#e $%o/eE8$18 2inu$ $e!e%t %o/e f#o2 $ +*e#e
$%o/eE8S28 2inu$ $e!e%t
%o/e f#o2 $ +*e#e $%o/eE8$"8 o# $%o/eE8$&8 o# $%o/eE8$187
:)0D;
!!!!!
p(
pD
2."1. Di$!a3 t*e $na2e in ue# %a$e5 !o+e# %a$e5 init%a %a$e an/ it$ !engt* f#o2
Su!ie#.
SQL. $e!e%t ue#($na2e)5!o+e#($na2e)5 init%a($na2e)5 !engt*($na2e) f#o2
$u!ie#7
%::;R5S@?M;7 L01;R5S@?M;7 #@#-)?:5S@?M;7 L;@,-F5S@?M;7
!!!!!!!!!! !!!!!!!!!! !!!!!!!!!! !!!!!!!!!!!!!
SM#-F smith Smith +
B0@;S 'ones Bones +
BL?L; &lake Blake +
)L?RL clark )lark +
?D?MS adams ?dams +
1G
". C#eate ta,!e ,i!! *a0ing fie!/$ %on$u2e# nu2,e#5 %on$u2en#na2e5
initia! #ea/ing an/ fina! #ea/ing +it*out $e%if3ing t*e #i2a#3 4e3.
SQL3 create ta&le &ill
" 5connum&er num&er5(7$
( conname varchar"5"<7$
* iMread num&er5+7$
+ fMread num&er5(779
-a&le created.
".1. In$e#t 0a!ue$ into t*e ta,!e ,i!!.
SQL. insert into &ill values5>connum&er$=>conname=$>iMread$>fMread79
;nter value for connum&er 1<<
;nter value for conname Bayakrishnan
;nter value for iMread (*<
;nter value for fMread +"+
old 1 insert into &ill values5>connum&er$=>conname=$>iMread$>fMread7
new 1 insert into &ill values51<<$=Bayakrishnan=$(*<$+"+7
1 row created.
SQL. ;
;nter value for connum&er 1<1
;nter value for conname Binu
;nter value for iMread *+D
;nter value for fMread DCG
old 1 insert into &ill values5>connum&er$=>conname=$>iMread$>fMread7
new 1 insert into &ill values51<1$=Binu=$*+D$DCG7
1 row created.
SQL. ;
;nter value for connum&er 1<"
;nter value for conname :hilip
;nter value for iMread "(+
;nter value for fMread +*E
old 1 insert into &ill values5>connum&er$=>conname=$>iMread$>fMread7
new 1 insert into &ill values51<"$=:hilip=$"(+$+*E7
1 row created.
SQL. ;
;nter value for connum&er 1<*
;nter value for conname Beneesh
1E
;nter value for iMread *("
;nter value for fMread GED
old 1 insert into &ill values5>connum&er$=>conname=$>iMread$>fMread7
new 1 insert into &ill values51<*$=Beneesh=$*("$GED7
1 row created.
SQL. ;
;nter value for connum&er 1<+
;nter value for conname Sony
;nter value for iMread *("
;nter value for fMread EGC
old 1 insert into &ill values5>connum&er$=>conname=$>iMread$>fMread7
new 1 insert into &ill values51<+$=Sony=$*("$EGC7
1 row created.
SQL. ;
;nter value for connum&er 1<D
;nter value for conname Resmy
;nter value for iMread "(<
;nter value for fMread EEE
old 1 insert into &ill values5>connum&er$=>conname=$>iMread$>fMread7
new 1 insert into &ill values51<D$=Resmy=$"(<$EEE7
1 row created.
".2. A// #i2a#3 4e3 to t*e ta,!e ,i!!.
SQL. ?lter ta&le &ill
" add primary key5connum&er79
-a&le altered.
".". Di$!a3 t*e /e$%#ition of t*e ,i!! afte# $e%if3ing %onnu2,e# a$
#i2a#3 4e3.
SQL. desc &ill9
@ame @ullN -ype
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!
)0@@%MB;R @0- @%LL @%MB;R5(7
)0@@?M; J?R)F?R"5"<7
#MR;?D @%MB;R5+7
OMR;?D @%MB;R5(7
"<
".&. Di$!a3 a!! /etai!$ afte# %*anging %onna2e #o Si#aK +*e#e
%onnu2,e# 161 u$ing u/ate
SQL. update &ill
" set connameP=Sira'= where connum&er P1<+9
1 row updated.
SQL. $e!e%t < f#o2 ,i!!7
)0@@%MB;R )0@@?M; #MR;?D OMR;?D
!!!!!!!!!! !!!!!!!!!!!!!!!!!!!! !!!!!!!!!! !!!!!!!!!!
1<< Bayakrishnan (*< +"+
1<1 Binu *+D DCG
1<" :hilip "(+ +*E
1<* Beneesh *(" GED
1<+ Sira' *(" EGC
1<D Resmy "(< EEE
D rows selected.
".1. C#eate a 0ie+ a$ ne+,i!! $*o+ing %onnu2,e# an/ %onna2e f#o2
,i!! ta,!e an/ /i$!a3 /etai!$ of ne+,i!!.
SQL. create view new&ill
" as
( select connum&er$conname from &ill
* 9
Jiew created.
SQL. select H from new&ill9
)0@@%MB;R )0@@?M;
!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!
1<< Bayakrishnan
1<1 Binu
1<" :hilip
1<* Beneesh
1<+ Sira'
1<D Resmy
D rows selected.
"1
".=. De!ete t*e 0ie+ ne+,i!!.
SQL. drop view new&ill9
Jiew dropped.
".B. Rena2e ta,!e ,i!! to ,i!!ing.
SQL. rename &ill to &illing9
-a&le renamed.
&. 9#og#a2 to fin/ t*e gi0en nu2,e# i$ o// o# e0en
SQL. D;)L?R;
" a num&er P>input9
( & num&er5"79
* &egin
+ &Pmod5a$"79
D if &P< then
C d&msMoutput.putMline5=-he given num&er is even=79
G else
E d&msMoutput.putMline5=-he given is odd=79
1< end if9
11 end9
1" Q
SQL. ;
;nter value for input +
old " a num&er P>input9
new " a num&er P+9
-he given is odd
:LQSQL procedure successfully completed.
SQL. ;
;nter value for input D
old " a num&er P>input9
new " a num&er PD9
T*e gi0en nu2,e# i$ e0en
:LQSQL procedure successfully completed.
""
1. 9#og#a2 to fin/ t*e !a#ge$t of t*#ee nu2,e#$
SQL. declare
" a num&er5(79
( & num&er5(79
* c num&er5(79
+ &egin
D aP>inputMa9
C &P>inputM&9
G cP>inputMc9
E if a3& and a3c then
1< d&msMoutput.putMline5aRR= is the largest num&er=79
11 elsif &3c then
1" d&msMoutput.putMline5&RR= is the largest num&er=79
1( else
1* d&msMoutput.putMline5cRR= is the largest num&er=79
1+ end if9
1D end9
1C Q
Outut
;nter value for inputMa 1<
old D aP>inputMa9
new D aP1<9
;nter value for inputM& E
old C &P>inputM&9
new C &PE9
;nter value for inputMc 1+
old G cP>inputMc9
new G cP1+9
11 i$ t*e !a#ge$t nu2,e#
:LQSQL procedure successfully completed.
"(
LE( TECMNOLOGY
"*
Ai2
1. C#ete iAMS +e, age
Sou#%e Co/e
4html3
4head3
4title3 #nstitution Details4Qtitle3
4style3
&ody
S
&ackground!color sky&lue9
color yellow9
&ackground!image url5university.'pg79
&ackground!attachment fi/ed9
T
h"
S
te/t!decoration underline9
T
4Qstyle3
4Qhead3
4&ody3
4h1 alignPUcenterU3#@-;R@?-#0@?L ?)?D;MA O0R M?@,;M;@-
SA%D#;S4Qh13
4? @amePU:oint1U3
4h" alignPUcenterU3Meads Lane$@ear Bu&ilee Fospital$:alayam$-hiruvananthapuram!
(*4Qh"3
4h( alignPUcenterU3-el o*C1!"("*E<D$"((*E<C$D*+*(+14Qh(3
4h* alignPUcenterU3
"+
4a hrefPUhttpQQwww.iamsinternational.comU3www.iamsinternational.com4Qa3
4Qh+3
4&rQ34&rQ34&rQ34&rQ3
4&rQ34&rQ34&rQ34&rQ3
4mar2uee directionPUrightU &ehaviorPUalternateU3
4h1 alignPUcenterU31;L)0M; -0 MA 1;B :?,;4Qh13
4Qmar2uee3
4ul3
4li34a hrefPUhttpQQwww.iamsinternational.comU3)ollege4Qa34Qli3
4li34a hrefPUhttpQQwww.google.eduU3,oogle4Qa34Qli3
4Qul3
4ul3
4li34a hrefPUhttpQQwww.iamsinternational.comU3)ollege4Qa34Qli3
4li34a hrefPUhttpQQwww.google.eduU3,oogle4Qa34Qli3
4Qul3
4h* alignPUcenterU3
4a hrefPUhttpQQwww.iamsinternational.comU3www.iamsinternational.com4Qa3
4Qh+3
4h+ alignPUcenterU3
4a hrefPUmailtoiamsinternationalVgmail.comU3;mail4Qa3
4Qh+3
4hr colorPUwhiteU3
4h+ alignPUcenterU3)opyright >copy9iams"<114Qh+3
4a hrefPUK:oint1U3%niversity4Q?3
4Qhr3
4Q&ody3
4Qhtml3
"D
OUT9UT
"C
Ai2
2. C#eate Ta,!e
Sou#%e Co/e
4F-ML3
4head3
4title3 -a&les 4Qtitle3
4Qhead3
4&ody3
4ta&le alignPcenter &orderP* cellspacingP" cellpaddingP1< widthPD<W3
4caption34&3Download ?ttachment4Q&34Qcaption3
4tr3
4th3Oile @ame4Qth3
4th colspanP"3 Download 4Qth3
4Qtr3
4tr alignPcenter3
4td rowspanP"3 ,oogly Oiles 4Qtd3
4td34a hrefPUU3with norton virus scanner 4Qa34Qtd3
4td34a hrefPUU3with Dr.soleman virus scanner4Qa34Qtd3
4Qtr3
4tr alignPcenter3
4td colspanP"34a hrefPUU31ithout scanning 4Qa34Qtd3
4Qtr3
4Qta&le3
4Q&ody3
4Qhtml3
"G
OUT9UT
"E
Ai2
". C#eate a '#a2e 'a2i!3
Sou#%e Co/e
4html3
4&ody &ackgroundPUheader.'pgU34&r34&r3
4&34ul3
4li3Mr ?noop
4li3Mrs Deepa
4li3Miss Ra'i
4Qul34Q&3
4Q&ody3
4Qhtml3
(<
4html3
4&ody &ackgroundPUFeader.'pgU3
4font facePU)omic Sans MSU34&r3
4center34F"3-he S)- Oamily4Qh"34Qcenter3
4Q&ody3
4Qhtml3
(1
4html3
4&ody &ackgroundPUFeader.'pgU34&r34&r3
4center34img heightP(<< srcPUe/plose.gifU widthP1+<3 4Qcenter3
4Q&ody3
4Qhtml3
4html3
("
4frameset rowsPUC<$HU3
4frame srcPUheader.htmlU marginheightP< marginwidthP< namePUframe1U3
4frameset colsPU(+W$HU3
4frame srcPUsctfamil.htmlU namePUframe"U3
4frame srcPUdesc.htmlU namePUframe(U3
4Qframeset3
4Qframeset3
4Qhtml3
((
OUT9UT
Ai2
(*
&. C#eate a 9a#entNC*i!/ +in/o+
Sou#%e Co/e
9a#ent +in/o+
4html3
4head3
4script typePUte/tQ'avascriptU3
function send57
S
var valPdocument.childform.childte/t&o/.value9
window.opener.document.parentform.parentte/t&o/.valuePval9
self.close579
T
4Qscript3
4Qhead3
4&ody3
4center3
4form namePUchildformU3
4h(3 -ype a te/t and click su&mit4Qh(3
4input typePUte/tU namePUchildte/t&o/UQ34&rQ3
4input typePU&uttonU namePchild&uttonU valuePUsu&mitU onclickPUsend57UQ34&rQ3
4Qform3
4Qcenter3
4Q&ody3
4Qhtml3
OUT9UT
(+
(D
C*i!/ +in/o+
4html3
4head3
4script typePUte/tQ'avascriptU3
function starts57
S
window.open5Uchild.htmlU79
T
4Qscript3
4Qhead3
4&ody3
4form namePUparentformU3
4center3
4h(3 )lick the open &utton4Qh(3
4input typePU&uttonU valuePUopenU onclickPUstarts57UQ3
4&rQ34&rQ3
4input typePUte/tU namePUparentte/t&o/UQ3
4Qcenter3
4Q&ody3
4Qhtml3
(C
OUT9UT
Ai2
(G
1. C#eate a age +it* !in4 to Ya*oo5 Goog!e5 O#4ut5G2ai! : Mot2ai! an/ +it* a
/e$%#ition on ?M3e#!in4ing in *t2!@
Sou#%e Co/e
4F-ML3
4head3
4title3 link 4Qtitle3
4Qhead3
4&ody3
4h" alignP center34%3 FA:;RL#@L#@, #@ F-ML4Qh"34Q%3
4p3
1ith F-ML tags we can create links within the same document and also to documents
present elsewhere on the we&.
4&r3
1ith the com&ination of links and %RL=s we can provide links through
4&3,opher$ O-:$ %S;@;-$ 4Q&3andso on.
4&r3-hus$ using F-ML link tags we can provide4&r3
4&r3
4&r34center3
17#ntra!document linking4&r3
"7#nter!document linking4&r3
(7Linking non!te/t o&'ects4&r3
4Qcenter3
4&r3
4&r3
4&r3
F-ML links are defined with the UaU tag.
4&r3
FR;O indicates hyperte/t reference.4&r3
we should specify the location of another resource or file name using this attri&ute.
(E
4&r3#f the anchor indicates the source then it would use this attri&ute.
4&r3
4&r3
4&r3
4a hrefPUhttpQQwww.google.comQU3google4Qa34&r3
4a hrefPUhttpQQwww.yahoo.comQU3yahoo4Qa34&r3
4a hrefPUhttpQQwww.gmail.comQU3gmail4Qa34&r3
4a hrefPUhttpQQwww.orkut.comQU3orkut4Qa34&r3
4a hrefPUhttpQQwww.hotmail.comQU3hotmail4Qa34&r3
4Q&ody3
4Qhtml3
OUT9UT
*<
HHHHHHHHHHHHHHHHHHHHHHHHHHHH
*1

Anda mungkin juga menyukai