You are on page 1of 37

Database Processing, Ninth Edition

Part 1 of 1 - 18.0/ 20.0 Points


Question 1 of 20
1.0/ 1.0 Points
Because SQL statements are set-oriented, whereas programs are element-oriented, the results o SQL statements
used in programs are accessed using !!!!!!!..
". standard programming tools
B. an SQL cursor
#. an SQL trigger
$. custom written programming tools
Question 2 of 20
0.0/ 1.0 Points
SQL Ser%er program code that is e&ecuted ater an SQL command has 'een processed is called a(n)*
". B+,-. trigger.
B. -.S/+"$ 01 trigger.
#. "1/+2 trigger.
$. B+102+ trigger.
Question 3 of 20
1.0/ 1.0 Points
3ith this t4pe o SQL Ser%er cursor concurrenc4 no loc5 is o'tained until the user updates the data.
". 0P/-6-S/-#
B. S#20LL7L0#8
#. P+SS-6-S/-#
$. 2+"$70.L9
Question 4 of 20
1.0/ 1.0 Points
SQL triggers are used or!!!!!!!!!
7 - 1
Chapter 7 - Database Processing, Ninth Edition
". %alidit4 chec5ing
B. pro%iding deault %alues
#. updating %iews
$. "ll o the mentioned options
Question 5 of 20
1.0/ 1.0 Points
:/he ollowing SQL statement is curror B;s data manipulation or ta'le ". 3hich is the correct character string to
'e entered in the 'lan5<
=P$"/+ " S+/ "2>1, "?>2 3@+2+ !!!!!!.
"("1, "2, "?) is the structure o ta'le ", the underline indicates the primar4 5e4:
". #=22+./ 01 B
B. "1>B
#. "1>#=22+./ 01 B
$. "1>B 01 "
Question 6 of 20
1.0/ 1.0 Points
SQL triggers can 'e used when the $B6S recei%es a 777777777777reAuest
". insert
B. delete
#. update
$. "ll o the mentioned options
Question 7 of 20
1.0/ 1.0 Points
3hich o the ollowing is true concerning a procedure<
". /he4 do not need to ha%e a uniAue name.
7 - 2
Chapter 7 - Database Processing, Ninth Edition
B. 9ou do not create them with SQL.
#. /he4 include procedural and SQL statements.
$. /he4 are the same thing as a unction.
Question 8 of 20
1.0/ 1.0 Points
9ou ha%e a third-part4 application that inserts data directl4 into a ta'le. 9ou add two new columns to the ta'le.
/hese columns cannot accept .=LL %alues and cannot use deault constraints. 9ou need to ensure that the new
columns do not 'rea5 the third-part4 application. 3hat should 4ou do<
".#reate a stored procedure.
B.#reate a $$L trigger.
#.#reate an "1/+2 -.S+2/ trigger.
$.#reate an -.S/+"$ 01 -.S+2/ trigger.
Question 9 of 20
1.0/ 1.0 Points
:9ou need to determine the result o e&ecuting this code segment.
$+#L"2+ B2angeStart -./ > 0C
$+#L"2+ B2ange+nd -./ > 10000C
$+#L"2+ B2angeStep -./ > 1C
3-/@ .um'er2ange(-temDalue)
"S (
S+L+#/ -temDalue
1206 (S+L+#/ B2angeStart "S -temDalue) "S t
=.-0. "LL
S+L+#/ -temDalue E B2angeStep
1206 .um'er2ange
3@+2+ -temDalue F B2ange+nd)
S+L+#/ -temDalue
1206 .um'er2ange
0P/-0. (6"G2+#=2S-0. 100)
3hich result will 'e returned< :
".10,001 rows will 'e returned with a ma&imum recursion error.
B.101 rows will 'e returned with a ma&imum recursion error.
7 - 3
Chapter 7 - Database Processing, Ninth Edition
#.101 rows will 'e returned with no error.
$.10,001 rows will 'e returned with no error.
Question 10 of 20
1.0/ 1.0 Points
" unction returns one %alue and has onl4 output parameters.
/rue
1alse
Question 11 of 20
1.0/ 1.0 Points
9ou are tas5ed to create a ta'le that has a column that must store the current time accurate to ten microseconds.
9ou need to use a s4stem unction in conHunction with the $+1"=L/ option in the column deinition. 3hich
s4stem unction should 4ou use<
".$"/+"$$
B.S9S$"/+/-6+
#.,+/=/#$"/+
$.#=22+./7/-6+S/"6P
Question 12 of 20
0.0/ 1.0 Points
3hich t4pe o SQL Ser%er cursor concurrenc4 places an update loc5 on a row when the row is read<
". S#20LL7L0#8
B. 2+"$#066-//+$
#. 2+"$70.L9
$. 0P/-6-S/-#
Question 13 of 20
1.0/ 1.0 Points
- a trigger is 'eing written to enorce reerential integrit4 actions, 4ou cannot use !!!!.
". a B+102+ trigger
7 - 4
Chapter 7 - Database Processing, Ninth Edition
B. an -.S/+"$ 01 trigger
#. an "1/+2 trigger
$. depending on the speciic reerential integrit4 action, either ' or c ma4 'e disallowed
Question 14 of 20
1.0/ 1.0 Points
9ou are responsi'le or a SQL Ser%er data'ase. 9ou reAuire the ta'les to 'e added or altered onl4 on the irst da4 o
the month. 9ou need to ensure that i the ta'les are attempted to 'e modiied or created on an4 other da4, an error
is recei%ed and the attempt is not successul. 3hich /ransact-SQL statement should 4ou use<
".:#2+"/+ /2-,,+2 /2,7/"BL+S70.71-2S/ 0. "LL S+2D+2 102 "L/+27$"/"B"S+ "S
-1 $"/+P"2/(da4,getdate())I1
B+,-.
20LLB"#8
2"-S+2202 (J6ust wait til ne&t month.J, 1K, 1)
+.$:
B.:#2+"/+ /2-,,+2 /2,7/"BL+S70.71-2S/ 0. $"/"B"S+ 102 #2+"/+7/"BL+,
"L/+27/"BL+ "S
-1 $"/+P"2/(da4,getdate())I1
B+,-.
2"-S+2202 (J6ust wait til ne&t month.J, 1K, 1)
+.$:
#.:#2+"/+ /2-,,+2 /2,7/"BL+S70.71-2S/
0. $"/"B"S+ 102 #2+"/+7/"BL+
"S
-1 $"/+P"2/(da4,getdate())I1
B+,-.
2"-S+2202 (J6ust wait til ne&t month.J, 1K, 1)
+.$:
$.:#2+"/+ /2-,,+2 /2,7/"BL+S70.71-2S/ 0. $"/"B"S+ 102 #2+"/+7/"BL+,
"L/+27/"BL+ "S
-1 $"/+P"2/(da4,getdate())I1
B+,-.
20LLB"#8
2"-S+2202 (J6ust wait til ne&t month.J, 1K, 1)
+.$:
Question 15 of 20
1.0/ 1.0 Points
SQL Ser%er 2000 stored procedures can*
".'e stored on the usersJ computer.
7 - 5
Chapter 7 - Database Processing, Ninth Edition
B.'e 5ept within the data'ase and in%o5ed '4 application programs.
#.support B+102+, -.S/+"$ 01 and "1/+2 t4pes.
$.ne%er 'e 5ept within the data'ase.
Question 16 of 20
1.0/ 1.0 Points
-n a relational data'ase s4stem, which o the ollowing SQL statements is used to e&tract rows speciied '4 the
cursor ater it has 'een deined<
". 1+/#@ statement
B. 2+"$ statement
#. $+#L"2+ statement
$. 0P+. statement
Question 17 of 20
1.0/ 1.0 Points
/he +nterprise manager cannot 'e used to modi4 stored procedures<
/rue
1alse
Question 18 of 20
1.0/ 1.0 Points
3hich o the ollowing statements is true concerning routines and triggers<
". Both consist o procedural code.
B. Both ha%e to 'e called to operate.
#. Both run automaticall4.
$. Both are stored in the data'ase.
Question 19 of 20
1.0/ 1.0 Points
9our data'ase contains two ta'les named $omesticSales0rders and -nternationalSales0rders. Both ta'les contain
more than 100 million rows. +ach ta'le has a Primar4 8e4 column named Sales0rder-d. /he data in the two ta'les
7 - 6
Chapter 7 - Database Processing, Ninth Edition
is distinct rom one another. Business users want a report that includes aggregate inormation a'out the total
num'er o glo'al sales and total sales amounts. 9ou need to ensure that 4our Auer4 e&ecutes in the minimum
possi'le time. 3hich Auer4 should 4ou use<
".:S+L+#/ #0=./(L) "S .um'er0Sales, S=6(Sales"mount) "S /otalSales"mount
1206 $omesticSales0rders
=.-0. "LL
S+L+#/ #0=./(L) "S .um'er0Sales, S=6(Sales"mount) "S /otalSales"mount
1206 -nternationalSales0rders
:
B.:S+L+#/ #0=./(L) "S .um'er0Sales, S=6(Sales"mount) "S /otalSales"mount
1206 (
S+L+#/ Sales0rder-d, Sales"mount
1206 $omesticSales0rders
=.-0.
S+L+#/ Sales0rder-d, Sales"mount
1206 -nternationalSales0rders
) "S p
:
#.:S+L+#/ #0=./(L) "S .um'er0Sales, S=6(Sales"mount) "S /otalSales"mount
1206 (
S+L+#/ Sales0rder-d, Sales"mount
1206 $omesticSales0rders
=.-0. "LL
S+L+#/ Sales0rder-d, Sales"mount
1206 -nternationalSales0rders
) "S p
:
$.:S+L+#/ #0=./(L) "S .um'er0Sales, S=6(Sales"mount) "S /otalSales"mount
1206 $omesticSales0rders
=.-0.
S+L+#/ #0=./(L) "S .um'er0Sales, S=6(Sales"mount) "S /otalSales"mount
1206 -nternationalSales0rders
:
Question 20 of 20
1.0/ 1.0 Points
" stored program that is attached to the data'ase is called 777777777777777777
". a %iew
B. a stored procedure
#. a #@+#8 constraint
7 - 7
Chapter 7 - Database Processing, Ninth Edition
$. a trigger
Question 1 of 20 1.0/ 1.0 Points
9our data'ase contains two ta'les named $omesticSales0rders and -nternationalSales0rders. Both ta'les contain
more than 100 million rows. +ach ta'le has a Primar4 8e4 column named Sales0rder-d. /he data in the two ta'les
is distinct rom one another. Business users want a report that includes aggregate inormation a'out the total num'er
o glo'al sales and total sales amounts. 9ou need to ensure that 4our Auer4 e&ecutes in the minimum possi'le time.
3hich Auer4 should 4ou use<
".:S+L+#/ #0=./(L) "S .um'er0Sales, S=6(Sales"mount) "S /otalSales"mount
1206 (
S+L+#/ Sales0rder-d, Sales"mount
1206 $omesticSales0rders
=.-0.
S+L+#/ Sales0rder-d, Sales"mount
1206 -nternationalSales0rders
) "S p
:
B.:S+L+#/ #0=./(L) "S .um'er0Sales, S=6(Sales"mount) "S /otalSales"mount
1206 $omesticSales0rders
=.-0.
S+L+#/ #0=./(L) "S .um'er0Sales, S=6(Sales"mount) "S /otalSales"mount
1206 -nternationalSales0rders
:
#.:S+L+#/ #0=./(L) "S .um'er0Sales, S=6(Sales"mount) "S /otalSales"mount
1206 $omesticSales0rders
=.-0. "LL
S+L+#/ #0=./(L) "S .um'er0Sales, S=6(Sales"mount) "S /otalSales"mount
1206 -nternationalSales0rders
:
$.:S+L+#/ #0=./(L) "S .um'er0Sales, S=6(Sales"mount) "S /otalSales"mount
1206 (
S+L+#/ Sales0rder-d, Sales"mount
1206 $omesticSales0rders
=.-0. "LL
S+L+#/ Sales0rder-d, Sales"mount
1206 -nternationalSales0rders
) "S p
:
Question 2 of 20 1.0/ 1.0 Points
3hich o the ollowing is true concerning triggers<
". /he4 ha%e an e%ent, condition, and action.
7 - 8
Chapter 7 - Database Processing, Ninth Edition
B. /he4 e&ecute against onl4 some applications that access a data'ase.
#. 9ou do not create them with SQL.
Question 3 of 20 1.0/ 1.0 Points
SQL Ser%er program code that is e&ecuted instead o an SQL command that needs to 'e processed is called a(n)*
". -.S/+"$ 01 trigger.
B. "1/+2 trigger.
#. B+,-. trigger.
$. B+102+ trigger.
Question 4 of 20 1.0/ 1.0 Points
+m'edded SQL is which o the ollowing<
"./he process o ma5ing an application capa'le o generating speciic SQL code on the l4.
B.@ard-coded SQL statements in a program language such as Ma%a.
#.@ard-coded SQL statements in a procedure.
$.@ard-coded SQL statements in a trigger.
Question 5 of 20 1.0/ 1.0 Points
3hich o the three possi'le t4pes o triggers does SQL Ser%er support<
". "1/+2 onl4
B. -.S/+"$ 01 and "1/+2 onl4
#. -.S/+"$ 01 onl4
$. B+102+ onl4
Question 6 of 20 1.0/ 1.0 Points
9ou ha%e a third-part4 application that inserts data directl4 into a ta'le. 9ou add two new columns to the ta'le.
/hese columns cannot accept .=LL %alues and cannot use deault constraints. 9ou need to ensure that the new
7 - 9
Chapter 7 - Database Processing, Ninth Edition
columns do not 'rea5 the third-part4 application. 3hat should 4ou do<
".#reate a $$L trigger.
B.#reate an "1/+2 -.S+2/ trigger.
#.#reate a stored procedure.
$.#reate an -.S/+"$ 01 -.S+2/ trigger.
Question 7 of 20 1.0/ 1.0 Points
3hich o the ollowing is an SQL trigger 6icrosot SQL Ser%er supports<
". B+102+
B. -.S/+"$ 01
#. "1/+2
$. ' and c onl4
Question 8 of 20 1.0/ 1.0 Points
/riggers are stored 'loc5s o code that ha%e to 'e called in order to operate.
/rue
1alse
Question 9 of 20 1.0/ 1.0 Points
9ou are tas5ed to create a ta'le that has a column that must store the current time accurate to ten microseconds. 9ou
need to use a s4stem unction in conHunction with the $+1"=L/ option in the column deinition. 3hich s4stem
unction should 4ou use<
".$"/+"$$
B.,+/=/#$"/+
#.S9S$"/+/-6+
$.#=22+./7/-6+S/"6P
Question 10 of 20 1.0/ 1.0 Points
7 - 10
Chapter 7 - Database Processing, Ninth Edition
9ou are responsi'le or a SQL Ser%er data'ase. 9ou reAuire the ta'les to 'e added or altered onl4 on the irst da4 o
the month. 9ou need to ensure that i the ta'les are attempted to 'e modiied or created on an4 other da4, an error is
recei%ed and the attempt is not successul. 3hich /ransact-SQL statement should 4ou use<
".:#2+"/+ /2-,,+2 /2,7/"BL+S70.71-2S/ 0. $"/"B"S+ 102 #2+"/+7/"BL+,
"L/+27/"BL+ "S
-1 $"/+P"2/(da4,getdate())I1
B+,-.
20LLB"#8
2"-S+2202 (J6ust wait til ne&t month.J, 1K, 1)
+.$:
B.:#2+"/+ /2-,,+2 /2,7/"BL+S70.71-2S/ 0. "LL S+2D+2 102 "L/+27$"/"B"S+ "S
-1 $"/+P"2/(da4,getdate())I1
B+,-.
20LLB"#8
2"-S+2202 (J6ust wait til ne&t month.J, 1K, 1)
+.$:
#.:#2+"/+ /2-,,+2 /2,7/"BL+S70.71-2S/ 0. $"/"B"S+ 102 #2+"/+7/"BL+,
"L/+27/"BL+ "S
-1 $"/+P"2/(da4,getdate())I1
B+,-.
2"-S+2202 (J6ust wait til ne&t month.J, 1K, 1)
+.$:
$.:#2+"/+ /2-,,+2 /2,7/"BL+S70.71-2S/
0. $"/"B"S+ 102 #2+"/+7/"BL+
"S
-1 $"/+P"2/(da4,getdate())I1
B+,-.
2"-S+2202 (J6ust wait til ne&t month.J, 1K, 1)
+.$:
Question 11 of 20 1.0/ 1.0 Points
:9ou need to determine the result o e&ecuting this code segment.
$+#L"2+ B2angeStart -./ > 0C
$+#L"2+ B2ange+nd -./ > 10000C
$+#L"2+ B2angeStep -./ > 1C
3-/@ .um'er2ange(-temDalue)
"S (
S+L+#/ -temDalue
1206 (S+L+#/ B2angeStart "S -temDalue) "S t
=.-0. "LL
S+L+#/ -temDalue E B2angeStep
1206 .um'er2ange
3@+2+ -temDalue F B2ange+nd)
S+L+#/ -temDalue
1206 .um'er2ange
0P/-0. (6"G2+#=2S-0. 100)
7 - 11
Chapter 7 - Database Processing, Ninth Edition
3hich result will 'e returned< :
".101 rows will 'e returned with no error.
B.101 rows will 'e returned with a ma&imum recursion error.
#.10,001 rows will 'e returned with a ma&imum recursion error.
$.10,001 rows will 'e returned with no error.
Question 12 of 20 1.0/ 1.0 Points
3hich t4pe o SQL Ser%er cursor concurrenc4 places an update loc5 on a row when the row is read<
". S#20LL7L0#8
B. 2+"$#066-//+$
#. 2+"$70.L9
$. 0P/-6-S/-#
Question 13 of 20 1.0/ 1.0 Points
" 777777777777777 is a stored program that is attached to a ta'le or a %iew.
". pseudoile
B. em'edded S+L+#/ statement
#. trigger
$. .one o the a'o%e is correct.
Question 14 of 20 1.0/ 1.0 Points
SQL Ser%er 2000 stored procedures can*
".'e stored on the usersJ computer.
B.support B+102+, -.S/+"$ 01 and "1/+2 t4pes.
7 - 12
Chapter 7 - Database Processing, Ninth Edition
#.'e 5ept within the data'ase and in%o5ed '4 application programs.
$.ne%er 'e 5ept within the data'ase.
Question 15 of 20 1.0/ 1.0 Points
SQL triggers can 'e used when the $B6S recei%es a 777777777777reAuest
". insert
B. delete
#. update
$. "ll o the mentioned options
Question 16 of 20 0.0/ 1.0 Points
3hich SQL trigger does SQL Ser%er .0/ support<
". B+102+
B. -.S/+"$ 01
#. SQL Ser%er supports all three.
$. "1/+2
Question 17 of 20 1.0/ 1.0 Points
/he code to create triggers and routines is stored in onl4 one location and is administered centrall4.
/rue
1alse
Question 18 of 20 1.0/ 1.0 Points
3hich o the ollowing is true concerning a procedure<
". /he4 do not need to ha%e a uniAue name.
B. /he4 include procedural and SQL statements.
7 - 13
Chapter 7 - Database Processing, Ninth Edition
#. /he4 are the same thing as a unction.
$. 9ou do not create them with SQL.
Question 19 of 20 1.0/ 1.0 Points
- a trigger is 'eing written to enorce reerential integrit4 actions, 4ou cannot use !!!!.
". a B+102+ trigger
B. an -.S/+"$ 01 trigger
#. an "1/+2 trigger
$. depending on the speciic reerential integrit4 action, either ' or c ma4 'e disallowed
Question 20 of 20 0.0/ 1.0 Points
9ou need to identi4, within a gi%en clause, i the month o 1e'ruar4 will contain 2N da4s or a speciied 4ear.
3hich o'Hect should 4ou use<
". Stored procedure
B.Scalar-%alued unction
#./a'le-%alued unction
$.$6L trigger
Part 1 of 1 - 1O.0/ 20.0 Points
Question 1 of 20
0.0/ 1.0 Points
:/he ollowing SQL statement is curror B;s data manipulation or ta'le ". 3hich is the correct character string to
'e entered in the 'lan5<
=P$"/+ " S+/ "2>1, "?>2 3@+2+ !!!!!!.
"("1, "2, "?) is the structure o ta'le ", the underline indicates the primar4 5e4:
". #=22+./ 01 B
B. "1>B
7 - 14
Chapter 7 - Database Processing, Ninth Edition
#. "1>#=22+./ 01 B
$. "1>B 01 "
Question 2 of 20
1.0/ 1.0 Points
SQL triggers are created using !!!!!!!!.
". the SQL #2+"/+ /2-,,+2 statement
B. the SQL /2-,,+2 statement
#. the SQL "$$ #0.S/2"-./ /2-,,+2 statement
$. the SQL "$$ /2-,,+2 statement
Question 3 of 20
1.0/ 1.0 Points
=nli5e application code, stored procedures are ne%er distri'uted to 777777777777777
". the $B6S
B. the client computers
#. the networ5 ser%ers
$. the data'ase ser%ers
Question 4 of 20
0.0/ 1.0 Points
3hich o the ollowing statements is true concerning routines and triggers<
". Both consist o procedural code.
B. Both ha%e to 'e called to operate.
#. Both run automaticall4.
$. Both are stored in the data'ase.
Question 5 of 20
1.0/ 1.0 Points
7 - 15
Chapter 7 - Database Processing, Ninth Edition
9our data'ase contains two ta'les named $omesticSales0rders and -nternationalSales0rders. Both ta'les contain
more than 100 million rows. +ach ta'le has a Primar4 8e4 column named Sales0rder-d. /he data in the two ta'les
is distinct rom one another. Business users want a report that includes aggregate inormation a'out the total num'er
o glo'al sales and total sales amounts. 9ou need to ensure that 4our Auer4 e&ecutes in the minimum possi'le time.
3hich Auer4 should 4ou use<
".:S+L+#/ #0=./(L) "S .um'er0Sales, S=6(Sales"mount) "S /otalSales"mount
1206 $omesticSales0rders
=.-0. "LL
S+L+#/ #0=./(L) "S .um'er0Sales, S=6(Sales"mount) "S /otalSales"mount
1206 -nternationalSales0rders
:
B.:S+L+#/ #0=./(L) "S .um'er0Sales, S=6(Sales"mount) "S /otalSales"mount
1206 (
S+L+#/ Sales0rder-d, Sales"mount
1206 $omesticSales0rders
=.-0.
S+L+#/ Sales0rder-d, Sales"mount
1206 -nternationalSales0rders
) "S p
:
#.:S+L+#/ #0=./(L) "S .um'er0Sales, S=6(Sales"mount) "S /otalSales"mount
1206 (
S+L+#/ Sales0rder-d, Sales"mount
1206 $omesticSales0rders
=.-0. "LL
S+L+#/ Sales0rder-d, Sales"mount
1206 -nternationalSales0rders
) "S p
:
$.:S+L+#/ #0=./(L) "S .um'er0Sales, S=6(Sales"mount) "S /otalSales"mount
1206 $omesticSales0rders
=.-0.
S+L+#/ #0=./(L) "S .um'er0Sales, S=6(Sales"mount) "S /otalSales"mount
1206 -nternationalSales0rders
:
Question 6 of 20
1.0/ 1.0 Points
3hat is not an ad%antage o stored procedures<
".SQL can 'e optimiPed
B.#ode sharing
#.,reater securit4
7 - 16
Chapter 7 - Database Processing, Ninth Edition
$.-ncreased networ5 traic
Question 7 of 20
1.0/ 1.0 Points
- a trigger is 'eing written to enorce reerential integrit4 actions, 4ou cannot use !!!!.
". a B+102+ trigger
B. an -.S/+"$ 01 trigger
#. an "1/+2 trigger
$. depending on the speciic reerential integrit4 action, either ' or c ma4 'e disallowed
Question 8 of 20
1.0/ 1.0 Points
9ou are tas5ed to create a ta'le that has a column that must store the current time accurate to ten microseconds. 9ou
need to use a s4stem unction in conHunction with the $+1"=L/ option in the column deinition. 3hich s4stem
unction should 4ou use<
".$"/+"$$
B.S9S$"/+/-6+
#.,+/=/#$"/+
$.#=22+./7/-6+S/"6P
Question 9 of 20
1.0/ 1.0 Points
3hich t4pe o SQL Ser%er cursor concurrenc4 places an update loc5 on a row when the row is read<
". S#20LL7L0#8
B. 2+"$#066-//+$
#. 2+"$70.L9
$. 0P/-6-S/-#
Question 10 of 20
1.0/ 1.0 Points
7 - 17
Chapter 7 - Database Processing, Ninth Edition
-n a relational data'ase s4stem, which o the ollowing SQL statements is used to e&tract rows speciied '4 the
cursor ater it has 'een deined<
". 1+/#@ statement
B. 2+"$ statement
#. $+#L"2+ statement
$. 0P+. statement
Question 11 of 20
1.0/ 1.0 Points
3ith this t4pe o SQL Ser%er cursor concurrenc4 no loc5 is o'tained until the user updates the data.
". 0P/-6-S/-#
B. S#20LL7L0#8
#. P+SS-6-S/-#
$. 2+"$70.L9
Question 12 of 20
0.0/ 1.0 Points
SQL Ser%er 2000 stored procedures can*
".'e stored on the usersJ computer.
B.'e 5ept within the data'ase and in%o5ed '4 application programs.
#.support B+102+, -.S/+"$ 01 and "1/+2 t4pes.
$.ne%er 'e 5ept within the data'ase.
Question 13 of 20
0.0/ 1.0 Points
SQL triggers can 'e used when the $B6S recei%es a 777777777777reAuest
". insert
7 - 18
Chapter 7 - Database Processing, Ninth Edition
B. delete
#. update
$. "ll o the mentioned options
Question 14 of 20
1.0/ 1.0 Points
3hich o the three possi'le t4pes o triggers does SQL Ser%er support<
". B+102+ onl4
B. "1/+2 onl4
#. -.S/+"$ 01 onl4
$. -.S/+"$ 01 and "1/+2 onl4
Question 15 of 20
1.0/ 1.0 Points
9ou are responsi'le or a SQL Ser%er data'ase. 9ou reAuire the ta'les to 'e added or altered onl4 on the irst da4 o
the month. 9ou need to ensure that i the ta'les are attempted to 'e modiied or created on an4 other da4, an error is
recei%ed and the attempt is not successul. 3hich /ransact-SQL statement should 4ou use<
".:#2+"/+ /2-,,+2 /2,7/"BL+S70.71-2S/ 0. "LL S+2D+2 102 "L/+27$"/"B"S+ "S
-1 $"/+P"2/(da4,getdate())I1
B+,-.
20LLB"#8
2"-S+2202 (J6ust wait til ne&t month.J, 1K, 1)
+.$:
B.:#2+"/+ /2-,,+2 /2,7/"BL+S70.71-2S/ 0. $"/"B"S+ 102 #2+"/+7/"BL+,
"L/+27/"BL+ "S
-1 $"/+P"2/(da4,getdate())I1
B+,-.
2"-S+2202 (J6ust wait til ne&t month.J, 1K, 1)
+.$:
#.:#2+"/+ /2-,,+2 /2,7/"BL+S70.71-2S/
0. $"/"B"S+ 102 #2+"/+7/"BL+
"S
-1 $"/+P"2/(da4,getdate())I1
B+,-.
2"-S+2202 (J6ust wait til ne&t month.J, 1K, 1)
+.$:
7 - 19
Chapter 7 - Database Processing, Ninth Edition
$.:#2+"/+ /2-,,+2 /2,7/"BL+S70.71-2S/ 0. $"/"B"S+ 102 #2+"/+7/"BL+,
"L/+27/"BL+ "S
-1 $"/+P"2/(da4,getdate())I1
B+,-.
20LLB"#8
2"-S+2202 (J6ust wait til ne&t month.J, 1K, 1)
+.$:
Question 16 of 20
1.0/ 1.0 Points
SQL Ser%er program code that is e&ecuted instead o an SQL command that needs to 'e processed is called a(n)*
". B+102+ trigger.
B. B+,-. trigger.
#. -.S/+"$ 01 trigger.
$. "1/+2 trigger.
Question 17 of 20
1.0/ 1.0 Points
/riggers are stored 'loc5s o code that ha%e to 'e called in order to operate.
/rue
1alse
Question 18 of 20
1.0/ 1.0 Points
" 777777777777777 is a stored program that is attached to a ta'le or a %iew.
". pseudoile
B. em'edded S+L+#/ statement
#. trigger
$. .one o the a'o%e is correct.
Question 19 of 20
0.0/ 1.0 Points
3hich o the ollowing is not an ".S- SQL trigger<
". -.S/+"$ 01 =P$"/+
7 - 20
Chapter 7 - Database Processing, Ninth Edition
B. B+102+ =P$"/+
#. -.S/+"$ 01 #0.S/2"-./
$. B+102+ -.S+2/
Question 20 of 20
0.0/ 1.0 Points
9ou need to identi4, within a gi%en clause, i the month o 1e'ruar4 will contain 2N da4s or a speciied 4ear.
3hich o'Hect should 4ou use<
".$6L trigger
B.Scalar-%alued unction
#. Stored procedure
$./a'le-%alued unction
CHAPTER 7
Using SQL in Applications
True-Fase Questions
1. 3hen a surrogate 5e4 is used in the child ta'le in an -$-dependent relationship
the relationship changes to a non-identi4ing relationship.
Answer: True Level: oderate
Page: !!"
2. /he SQL 5e4word #0.S/2"-./ is used to limit column %alues to speciic %alues.
Answer: #alse Level: eas$
Page: !%%
?. "n SQL %irtual ta'le is called a %iew.
Answer: True Level: eas$
Page: !%&
O. /he SQL command #2+"/+ =S+2 D-+3 is used to create a %irtual ta'le.
7 - 21
Chapter 7 - Database Processing, Ninth Edition
Answer: #alse Level: oderate
Page: !%&
Q. SQL %iews are constructed rom S+L+#/ statements.
Answer: True Level: oderate
Page: !%&
K. "ccording to the SQL-N2, statements used to construct %iews cannot contain
the 3@+2+ clause.
Answer: #alse Level: oderate
Page: !%&
R. /he SQL command S+L+#/ is used to retrie%e %iew instances.
Answer: True Level: eas$
Page: !%&
8. SQL %iews can 'e used to hide columns.
Answer: True Level: eas$
Page: !%'
N. SQL %iews can 'e use used to pro%ide a le%el o indirection 'etween
data processed '4 applications and the data actuall4 stored in the data'ase ta'les.
Answer: True Level: oderate
Page: !%'
7 - 22
Chapter 7 - Database Processing, Ninth Edition
10. - the %alues in an SQL %iew are changea'le through the %iew itsel, the SQL command
=P$"/+ is used to change the %alues.
Answer: True Level: oderate
Page: !(%
11. /he %alues in an SQL %iew are alwa4s changea'le through the %iew itsel.
Answer: #alse Level: oderate
Page: !(%
12. SQL %iews are updatea'le when the %iew is 'ased on a single ta'le
with no computed columns, and all non-null columns are present in the %iew.
Answer: True Level: hard
Page: !(%-!(( )See #igure 7-*%+
1?. SQL %iews are identical to ".S-/SP"2# e&ternal schemas /user %iews.
Answer: #alse Level: oderate
Page: !((
1O. " set o SQL statements stored in an application written in a standard programming
language is called em'edded SQL.
Answer: True Level: eas$
Page: !(&
1Q. Because SQL statements are set-oriented, whereas programs are element-oriented, the results o
SQL statements used in programs are treated as iles.
Answer: #alse Level: oderate
Page: !(&
1K. Because SQL statements are set-oriented, whereas programs are element-oriented, the results o
SQL statements used in programs are accessed using an SQL cursor.
Answer: True Level: oderate
Page: !(&
1R. " stored program that is attached to a ta'le or %iew is called a stored procedure.
Answer: #alse Level: oderate
Page: !(,
18. SQL triggers are used or %alidit4 chec5ing, pro%iding deault %alues, and updating %iews.
Answer: True Level: eas$
Page: !(,
1N. B+102+ =P$"/+ is an ".S- SQL trigger.
Answer: True Level: oderate
Page: !(,
20. /he 0racle $B6S supports the SQL trigger B+102+.
Answer: True Level: oderate
Page: !(,
7 - 23
Chapter 7 - Database Processing, Ninth Edition
21. /he SQL Ser%er $B6S supports the SQL trigger B+102+.
Answer: #alse Level: oderate
Page: !(,
22. SQL triggers can 'e used when the $B6S recei%es an insert reAuest.
Answer: True Level: eas$
Page: !(,
2?. 3hen a trigger is ired, the $B6S ma5es the appropriate data a%aila'le to the application code.
Answer: #alse Level: hard
Page: !(,
2O. SQL triggers are created using the SQL "$$ /2-,,+2 statement.
Answer: #alse Level: hard
Page: !(7 )See #igure 7-*(+
2Q. /o add a single initial %alue to a column, 4ou would use the SQL $+1"=L/ constraint
with the #2+"/+ /"BL+ command.
Answer: True Level: hard
Page: !(7
2K. /o set a column %alue to an initial %alue that is selected according to some 'usiness logic,
4ou would use the SQL $+1"=L/ constraint with the #2+"/+ /"BL+ command.
Answer: #alse Level: hard
Page: !(7
2R. - the %alues in an SQL %iew are not changea'le through the %iew itsel, 4ou ma4 still 'e a'le
to update the %iew '4 using uniAue application logic. -n this case, the speciic logic is placed in
an -.S/+"$ 01 trigger.
Answer: True Level: hard
Page: !('
28. - a trigger is 'eing written to enorce reerential integrit4 actions,
4ou cannot use an -.S/+"$ 01 trigger.
Answer: #alse Level: hard
Page: !&*
2N. " stored program that is attached to the data'ase is called a trigger.
Answer: #alse Level: oderate
Page: !&*
?0. Stored procedures ha%e the ad%antage o greater securit4, decreased networ5 traic,
SQL optimiPed '4 the $B6S compiler, and code sharing.
Answer: True Level: oderate
Page: !&*-!&%
7 - 24
Chapter 7 - Database Processing, Ninth Edition
?1. =nli5e application code, stored procedures are ne%er distri'uted to the client computers.
Answer: True Level: oderate
Page: !&!
?2. Because SQL stored procedures allow and encourage code sharing among de%elopers,
stored procedures gi%e data'ase application de%elopers the ad%antages o less wor5,
standardiPed processing, and specialiPation among de%elopers.
Answer: True Level: oderate
Page: !&! )See #igure 7-*"+
!uti"e C#oi$e Questions
??. 3hen a surrogate 5e4 is used in the child ta'le in an -$-dependent relationship .
a.) the parent ta'le 'ecomes the holder o the oreign 5e4 or the relationship
'.) the surrogate 5e4 is allowed to contain null %alues
c.) the surrogate 5e4 is allowed to contain non-uniAue %alues
%&' t#e reations#i" $#an(es to a non-i%entif)in( reations#i"
e.) "ll o the a'o%e.
Level: oderate
Page: !!"
?O. ,i%en the SQL statement
#2+"/+ /"BL+ S"L+S2+P(
Sales2ep.o int .0/ .=LL,
2ep.ame char(?Q) .0/ .=LL,
@ire$ate date .0/ .=LL,
#0.S/2"-./ Sales2epP8 P2-6"29 8+9 (Sales2ep.o),
#0.S/2"-./ Sales2ep"81 =.-Q=+ (2ep.ame))*
we 5now that .
a.) 2ep.ame is the primar4 5e4
'.) 2ep.ame is a oreign 5e4
$&' Re"*a+e is a $an%i%ate ,e)
d.) 2ep.ame is a surrogate 5e4
e.) none o the a'o%e is true
Level: hard
Page: !!"-!%(
7 - 25
Chapter 7 - Database Processing, Ninth Edition
%&. /he SQL 5e4word used to limit column %alues to speciic %alues is .
a.) #0.S/2"-./
-&' CHEC.
c.) .0/ .=LL
d.) =.-Q=+
e.) =P$"/+
Level: eas$
Page: !%%
?K. "n SQL %irtual ta'le is called 777777777777777777 .
a.) a #@+#8 constraint
-&' a /ie0
c.) em'edded SQL
d.) a trigger
e.) a stored procedure
Level: eas$
Page: !%&
?R. /he SQL command used to create a %irtual ta'le is .
a.) #2+"/+ D/"BL+
-&' CREATE 12E3
c.) D/"BL+
d.) D-+3
e.) .+3L008
Level: oderate
Page: !%&
?8. SQL %iews are constructed rom .
a.) #2+"/+ statements
'.) -.S+2/ statements
c.) =P$"/+ statements
%&' 4E5ECT state+ents
e.) D-+3 statements
Level: oderate
Page: !%&
?N. "ccording to the SQL-N2, statements used to construct %iews cannot contain .
a.) the S+L+#/ clause
'.) the 1206 clause
c.) the 3@+2+ clause
%&' t#e 6R7ER 89 $ause
e.) SQL %iew statements can use all o the listed clauses
Level: oderate
Page: !%&
7 - 26
Chapter 7 - Database Processing, Ninth Edition
O0. 3hich SQL statement is used to retrie%e %iew instances<
a.) #2+"/+
'.) $+L+/+
c.) -.S+2/
%&' 4E5ECT
e.) =P$"/+
Level: eas$
Page: !%&
O1. SQL %iews are used .
a.) to hide columns
'.) to show results o computed columns
c.) to hide complicated $QL statements
d.) to pro%ide a le%el o indirection 'etween data processed '4 applications
and the data actuall4 stored in the data'ase ta'les
e&' 4Q5 /ie0s are use% for a of t#e a-o/e
Level: eas$
Page: !%'
O2. - the %alues in an SQL %iew are changea'le through the %iew itsel, which SQL statement
is used to change the %alues<
a.) #2+"/+
'.) $+L+/+
c.) -.S+2/
d.) S+L+#/
e&' :P7ATE
Level: oderate
Page: !(%
O?. 3hen are the %alues in an SQL %iew changea'le through the %iew itsel<
a) alwa4s
'.) not alwa4s, 'ut the rules to determine modiication status are simple
c.) not alwa4s, and the rules to determine modiication status are complicated
d.) not alwa4s, and the rules to determine modiication status are $B6S-dependent
e&' $ an% %
Level: oderate
Page: !(%
7 - 27
Chapter 7 - Database Processing, Ninth Edition
OO. SQL %iews are alwa4s updatea'le when .
a.) the %iew is 'ased on a single ta'le with no computed columns,
and all non-null columns are present in the %iew
'.) the %iew is 'ased on an4 num'er o ta'les, with or without computed columns,
and the -.S/+"$ 01 trigger is deined or the %iew
c.) the %iew is 'ased on multiple ta'les, the update is 'eing done on the most su'ordinate
ta'le, and the rows o that ta'le can 'e uniAuel4 identiied
%&' a an% -
e.) a, ' and c
Level: hard
Page: !(%-!(( )See #igure 7-*%+
OQ. @ow do SQL %iews compare to ".S-/SP"2# e&ternal schemas /user %iews<
a.) the4 are identical
-&' 4Q5 /ie0s are a su-set of A*42;4PARC user /ie0s
c.) ".S-/SP"2# user %iews are a su'set o SQL %iews
d.) the4 are completel4 dierent, with an unortunate similarit4 in their names
e.) either ' or c is correct depending on the particular data'ase
Level: oderate
Page: !((
OK. " set o SQL statements stored in an application written in a standard programming
language is called 777777777777777777 .
a.) a #@+#8 constraint
'.) a %iew
$&' e+-e%%e% 4Q5
d.) a trigger
e.) a stored procedure
Level: eas$
Page: !(&
OR. Because SQL statements are set-oriented, whereas programs are element-oriented, the results o
SQL statements used in programs are treated as 777777777777777777 .
a.) ta'les
'.) columns
c.) rows
d.) iles
e&' "seu%ofies
Level: oderate
Page: !(&
7 - 28
Chapter 7 - Database Processing, Ninth Edition
O8. Because SQL statements are set-oriented, whereas programs are element-oriented, the results o
SQL statements used in programs are accessed using .
a.) standard programming tools
'.) custom written programming tools
$&' an 4Q5 $ursor
d.) an SQL trigger
e.) an SQL stored procedure
Level: oderate
Page: !(&
ON. " stored program that is attached to a ta'le or %iew is called 777777777777777777 .
a.) a #@+#8 constraint
'.) a %iew
c.) em'edded SQL
%&' a tri((er
e.) a stored procedure
Level: eas$
Page: !(,
Q0. SQL triggers are used or .
a.) %alidit4 chec5ing
'.) pro%iding deault %alues
c.) updating %iews
d.) a and '
e&' a< - an% $
Level: eas$
Page: !(,
Q1. 3hich o the ollowing is not an ".S- SQL trigger<
a.) B+102+ =P$"/+
'.) -.S/+"$ 01 =P$"/+
c.) B+102+ -.S+2/
%&' 2*4TEA7 6F C6*4TRA2*T
e.) "1/+2 $+L+/+
Level: hard
Page: !(,
7 - 29
Chapter 7 - Database Processing, Ninth Edition
Q2. 3hich o the ollowing is an SQL trigger 0racle supports<
a.) B+102+
'.) -.S/+"$ 01
c.) "1/+2
d.) ' and c onl4
e&' a< - an% $
Level: oderate
Page: !(,
Q?. 3hich o the ollowing is an SQL trigger 6icrosot SQL Ser%er supports<
a.) B+102+
'.) -.S/+"$ 01
c.) "1/+2
%&' - an% $ on)
e.) a, ' and c
Level: oderate
Page: !(,
QO. SQL triggers can 'e used when the $B6S recei%es a 777777777777reAuest.
a.) insert
'.) update
c.) delete
d.) a and '
e&' a< - an% $
Level: eas$
Page: !(,
QQ. 3hen a trigger is ired, the $B6S ma5es the appropriate data a%aila'le to .
a.) the SQL interpreter
'.) the application code
c.) the em'edded SQL code
%&' t#e tri((er $o%e
e.) the stored procedure code
Level: eas$
Page: !(,
QK. SQL triggers are created using .
a&' t#e 4Q5 CREATE TR2==ER state+ent
'.) the SQL "$$ /2-,,+2 statement
c.) the SQL /2-,,+2 statement
d.) the SQL "$$ #0.S/2"-./ /2-,,+2 statement
e.) the SQL #0.S/2"-./ /2-,,+2 statement
Level: hard
Page: !(7 )See #igure 7-*(+
7 - 30
Chapter 7 - Database Processing, Ninth Edition
QR. /o add a single initial %alue to a column, 4ou would use*
a&' t#e 4Q5 7EFA:5T $onstraint 0it# t#e CREATE TA85E $o++an%&
'.) an SQL %iew.
c.) em'edded SQL.
d.) an SQL trigger.
e.) an SQL stored procedure.
Level: oderate
Page: !(7
Q8. /o set a column %alue to an initial %alue that is selected according to some 'usiness logic,
4ou would use*
a.) the SQL $+1"=L/ constraint with the #2+"/+ /"BL+ command.
'.) an SQL %iew.
c.) em'edded SQL.
%&' an 4Q5 tri((er&
e.) an SQL stored procedure.
Level: oderate
Page: !(7
QN. - the %alues in an SQL %iew are not changea'le through the %iew itsel, 4ou ma4 still 'e a'le
to update the %iew '4 using uniAue application logic. -n this case, the speciic logic is placed in .
a.) a B+102+ trigger
-&' an 2*4TEA7 6F tri((er
c.) an "1/+2 trigger
d.) depending on the speciic logic, either a or ' can 'e used
e.) depending on the speciic logic, an4 o a, ' or c can 'e used
Level: hard
Page: !('
K0. - a trigger is 'eing written to enorce reerential integrit4 actions, 4ou cannot use .
a.) a B+102+ trigger
'.) an -.S/+"$ 01 trigger
$&' an AFTER tri((er
d.) depending on the speciic reerential integrit4 action, either ' or c ma4 'e disallowed
e.) depending on the speciic reerential integrit4 action, an4 o a, ' or c ma4 'e disallowed
Level: hard
Page: !&-
7 - 31
Chapter 7 - Database Processing, Ninth Edition
K1. " stored program that is attached to the data'ase is called 777777777777777777 .
a.) a #@+#8 constraint
'.) a %iew
c.) em'edded SQL
d.) a trigger
e&' a store% "ro$e%ure
Level: eas$
Page: !&*
K2. Stored procedures ha%e the ad%antage o .
a.) greater securit4
'.) decreased networ5 traic
c.) SQL optimiPed '4 the $B6S compiler
d.) code sharing
e&' A of t#e a-o/e&
Level: eas$
Page: !&*-!&% )See #igure 7-*"+
K?. =nli5e application code, stored procedures are ne%er distri'uted to 777777777777777 .
a.) the $B6S
-&' t#e $ient $o+"uters
c.) the networ5 ser%ers
d.) the data'ase ser%ers
e.) "ll o the a'o%e.
Level: oderate
Page: !&*
KO. Because SQL stored procedures allow and encourage code sharing among de%elopers, stored
procedures gi%e data'ase application de%elopers the ad%antages o .
a.) less wor5
'.) standardiPed processing
c.) specialiPation among de%elopers
d.) a and '
e&' a< - an% $
Level: oderate
Page: !&! )See #igure 7-*"+
7 - 32
Chapter 7 - Database Processing, Ninth Edition
Fi in t#e 8an, Questions
KQ. 3hen a surrogate 5e4 is used in the child ta'le in an -$-dependent relationship
the relationship changes to a(n) non-identi.$ing relationship .
Level: oderate
Page: !!"
KK. /he SQL 5e4word C/EC0 is used to limit column %alues to speciic %alues.
Level: eas$
Page: !%%
KR. "n SQL %irtual ta'le is called a 1ie2 .
Level: eas$
Page: !%&
K8. /he SQL command C3EATE 45E6 is used to create a %irtual ta'le.
Level: eas$
Page: !%&
KN. SQL %iews are constructed rom SELECT statements.
Level: oderate
Page: !%&
R0. "ccording to the SQL-N2, statements used to construct %iews cannot contain
the 73DE3 89 clause.
Level: oderate
Page: !%&
R1. /he SQL command SELECT is used to retrie%e %iew instances.
Level: eas$
Page: !%&
R2. SQL %iews can 'e used to hide ta'le coluns .
Level: eas$
Page: !%'
R?. - the %alues in an SQL %iew are changea'le through the %iew itsel,
the SQL command UPDATE is used to change the %alues.
Level: oderate
Page: !(%
RO. /he %alues in an SQL %iew are not alwa4s changea'le through the 1ie2 itsel. .
Level: oderate
Page: !((
7 - 33
Chapter 7 - Database Processing, Ninth Edition
RQ. 3hen an SQL %iew is 'ased on a single ta'le with no computed columns, and all
non-null columns are present in the %iew, then the %iew is updateable .
Level: oderate
Page: !(%-!(( )See #igure 7-*%+
RK. SQL %iews are a subset o. ".S-/SP"2# e&ternal schemas /user %iews.
Level: oderate
Page: !((
RR. " set o SQL statements stored in an application written in a standard programming
language is called ebedded SQL .
Level: eas$
Page: !((
R8. Because SQL statements are set-oriented, whereas programs are element-oriented, the results o
SQL statements used in programs are treated as pseudo.iles .
Level: oderate
Page: !(&
RN. Because SQL statements are set-oriented, whereas programs are element-oriented, the results o
SQL statements used in programs are accessed using a(n) SQL cursor .
Level: oderate
Page: !(&
80. " stored program that is attached to a ta'le or %iew is called a(n) SQL trigger .
Level: eas$
Page: !(,
81. SQL triggers use the ".S- SQL 5e4words 8E#73E , 5NSTEAD 7# , and A#TE3 .
Level: oderate
Page: !(,
82. SQL triggers can 'e used with SQL operations 5NSE3T , UPDATE , and DELETE .
Level: oderate
Page: !(,
8?. /he 0racle $B6S supports the SQL triggers 8E#73E, 5NSTEAD 7# , and A#TE3 :
Level: oderate
Page: !(,
8O. /he SQL Ser%er $B6S does not support the SQL trigger 8E#73E .
Level: oderate
Page: !(,
8Q. SQL triggers can 'e used when the $B6S recei%es an insert reAuest.
Level: eas$
Page: !(,
7 - 34
Chapter 7 - Database Processing, Ninth Edition
8K. 3hen a trigger is ired, the $B6S ma5es the appropriate data a%aila'le to the trigger code .
Level: hard
Page: !(,
8R. SQL triggers are created using the SQL C3EATE T35;;E3 statement.
Level: hard
Page: !(, )See #igure 7-*(+
88. /o add a single initial %alue to a column, 4ou would use the SQL DE#AULT constraint .
Level: hard
Page: !(,
8N. /o set a column %alue to an initial %alue that is selected according to some 'usiness logic,
4ou would use an SQL trigger .
Level: oderate
Page: !(,
N0. - the %alues in an SQL %iew are not changea'le through the %iew itsel, 4ou ma4 still 'e a'le
to update the %iew '4 using uniAue application logic. -n this case, the speciic logic is placed in
an 5NSTEAD 7# trigger.
Level: hard
Page: !('
N1. - a trigger is 'eing written to enorce reerential integrit4 actions,
4ou cannot use an A#TE3 trigger.
Level: hard
Page: !&-
N2. " stored program that is attached to the data'ase is called a stored procedure .
Level: oderate
Page: !&*
N?. -n terms o application securit4, stored procedures are ore secure than application code.
Level: oderate
Page: !&*-!&%
NO. =nli5e application code, stored procedures are ne1er distributed to the client computers.
Level: oderate
Page: !&*
NQ. SQL Stored procedures gi%e data'ase application de%elopers the ad%antages o less wor5,
standardiPed processing, and specialiPation among de%elopers 'ecause stored procedures
allow and encourage code sharing among de%elopers.
Level: oderate
Page: !&! )See #igure 7-*"+
7 - 35
Chapter 7 - Database Processing, Ninth Edition
Essa) Questions
*ote to instru$tor> /he ollowing data'ase is should 'e pro%ided to students as the 'asis or SQL
e&amples reAuired '4 some o the Auestions that ollow.
=E*ERA5 4A5E4 7ATA8A4E>
4A5E4REP
4aesRe"*o Re"*a+e Hire7ate
KQO Mones 01/02/1NNN
R?O Smith 02/0?/2000
?OQ #hen 01/2Q/1NN8
O?O Mohnson 11/2?/1NN8
C:4T6!ER
Cust*o Cust*a+e 8aan$e 4aesRe"*o
N8R0 3inston Q00 ?OQ
8QN0 ,onPales ?Q0 O?O
R8O0 @arris 800 KQO
O8R0 6iles 100 ?OQ
NK. 3hat is an SQL %iew, and what is it used or< -nclude an e&ample 'ased on the #=S/06+2
ta'le o the ,eneral Sales $ata'ase.
An SQL 1ie2 is a 1irtual table constructed .ro database tables or other 1ie2s: 5t is based on the
SQL C3EATE 45E6 coand and uses the SQL SELECT stateent to construct the 1ie2:
/o2e1er, the 73DE3 89 clause cannot be used 2hen creating a 1ie2: #or e<aple=
C3EATE 45E6 CustoerNae7nl$ AS
SELECT CustNae
#37> CUST7>E3?
A 1ie2 a$ be used to @*A hide coluns or ro2s, @!A sho2 the results o. coputed coluns, @%A
hide coplicated SQL stateents such as Boins, and @(A pro1ide a le1el o. indirection bet2een the
data processed b$ applications and the actual table data:
NR. #ompare SQL %iews and the ".S-/SP"2# e&ternal schema/user %iew.
An SQL 1ie2 is a 1irtual table constructed .ro database tables or other 1ie2s: The
ANS5CSPA3C e<ternal scheaCuser 1ie2 is a particular 1ie2 o. a portion o. the database as seen
b$ an end user through a .or in an application: 6hile an SQL 1ie2 is based on a single
SELECT stateent, the user 1ie2 seen on the .or a$ be based on the results .ro ore than
one SELECT stateent: There.ore, 2hile the t2o are not the sae, 2e can consider that the SQL
1ie2 is a subset o. the ANS5CSPA3C e<ternal schea C user 1ie2:
7 - 36
Chapter 7 - Database Processing, Ninth Edition
N8. 3hat is em'edded SQL, and what considerations are necessar4 when using it in an application<
Ebedded SQL are SQL stateents used, or ebedded, in progra code, triggers or stored
procedures: Applications are t$picall$ 2ritten in progra code, using a prograing language:
There are t2o probles that arise: #irst, the results o. SQL stateents ust be assigned to
prograing language 1ariables: D8>S products t$picall$ pro1ide the eans o. doing this:
Second, SQL is set-oriented and SQL results use tables or sets o. ro2s, 2hereas application
prograing languages are eleent- or ro2-oriented: This is resol1ed b$ treating SQL results
as pseudo-.iles: A cursor is then used to o1e through the pseudo.ile one ro2 at a tie:
NN. 3hat are SQL triggers and how are the4 used<
An SQL trigger is a stored progra that is attached to a table or 1ie2: The trigger is in1oDed b$
the D8>S 2hene1er an insert, update or delete reEuest is ade on the table or 1ie2 2ith the
trigger: There are three coonl$ used triggers= 8E#73E, 5NSTEAD 7#, and A#TE3 @>S SQL
ser1er does not support 8E#73EA: This creates a set o. nine possible trigger t$pes= 8E#73E F
)5NSE3T or UPDATE or DELETE+, 5NSTEAD 7# F )5NSE3T or UPDATE or DELETE+, and
A#TE3 F )5NSE3T or UPDATE or DELETE+: Triggers are used @aong other thingsA .or @*A
1alidit$ checDing, @!A pro1iding de.ault 1alues, @%A updating 1ie2s, and @(A en.orcing re.erential
integrit$ actions:
100. 3hat are SQL stored procedures and how are the4 used<
An SQL stored procedure is a stored progra that is attached to a database, instead o. Bust a
table or 1ie2: Stored procedures can recei1e input paraeters and return results: The$ can be
e<ecuted b$ an$ process that has perission 2ith the database to use stored procedure: The$ are
t$picall$ used b$ @*A database adinistrators to do coon adinistrati1e tasDs, and @!A
database applications:
7 - 37

You might also like