Professional Documents
Culture Documents
(Chapter 1 - 7)
Chapter 1
1.
A RDBMS groups data in a logical manner into tables and manages the access to the tables. Yes No A table always has columns and rows. No Yes A schema diagram is used to understand a database!s design. No Yes A column in a table de#ined as N$% N&'' is a primary or #oreign (ey. No Yes Re#erential integrity is en#orced by the relationship between the primary (ey and #oreign (ey. Yes No
2.
".
).
Additional *+A #or ,hapters 1-./ Oracle SQL by Example by Alice Rischert/ 0rentice 1all 223345 0age 1 o# 16 7ersion8 )9292334
1.
2.
No
A table always has columns and rows. Note: A table can exist without rows but must have at least one column.
3.
Yes
4.
No
5.
Yes
Re!erential integrity is en!orced by the relationship between primary &ey and !oreign &ey.
,hapter 2
1.
Any column in a table is a candidate #or the S:':,% list. Yes No
2.
%he (eywords D;S%;N,% and &N;*&: cannot be used interchangeably in a S:':,% list. No Yes %he D:S,R;B: command is a S*' command. No Yes <iles sa=ed with a .s>l e?tension can be e?ecuted with the @ command.
Additional *+A #or ,hapters 1-./ Oracle SQL by Example by Alice Rischert/ 0rentice 1all 223345 0age 2 o# 16 7ersion8 )9292334
".
Yes No
).
%he push pin icon in S*' De=eloper allows you to toggle between the wor(sheets. Yes No %he S*'A0lus bu##er shows the last S*' command you typed. No Yes An $racle database re>uires that a user ha=e a user id and password to communicate with it. Yes No You can store at most "C333 characters in a 7AR,1AR2 column. Yes No You must always type column and table names in lowercase letters #or the S*' statement to e?ecute correctly. Yes No
6.
..
B.
4.
2.
No
3.
No
4.
Yes
+iles saved with a .s,l extension can be executed with the command.
5.
No
#he push pin icon in S*% Developer allows you to toggle between the wor&sheets.
Additional *+A #or ,hapters 1-./ Oracle SQL by Example by Alice Rischert/ 0rentice 1all 223345 0age o# 16 7ersion8 )9292334
6.
Yes
#he S*%./lus bu!!er shows the last S*% command you typed.
7.
Yes
An "racle database re,uires that a user have a user id and password to communicate with it.
8.
Yes
9.
No
0ou must always type column and table names in lowercase letters !or the S*% statement to execute correctly.
Note: #he S*% language s &eywords are not case8sensitive. +or clarity and readability you !ollow a naming convention. #he convention used in this boo& is listed in Appendix B2 9S*% +ormatting :uidelines.9
,hapter
1.
%he B:%D::N operator tests #or a range o# =alues. Yes No
2.
;t is not possible to limit the number o# rows returned #rom a S:':,% statement. No Yes You can test #or null =alues by using an empty string such as the #ollowing8 SELECT * FROM course WHERE prerequisite = ''. No Yes %he optional (eyword AS can precede the alias name. Yes No %he AND and $R logical operators can only be combined with the use o# parentheses.
Additional *+A #or ,hapters 1-./ Oracle SQL by Example by Alice Rischert/ 0rentice 1all 223345 0age " o# 16 7ersion8 )9292334
".
).
Yes No
6.
%he $RD:R BY clause must #ollow the D1:R: clause. No Yes %he #ollowing notation starts a multi-line comment. 9A Yes No A pseudocolumn such as R$DN&M is not actually stored in the database. Yes No %he underscore wildcard character can match multiple characters. Yes No
..
B.
4.
2.
No
)t is not possible to limit the number o! rows returned !rom a S'%'(# statement. Note: #he ;5'R' clause allows you to restrict the number o! rows returned by the ,uery.
3.
No
0ou can test !or null values by using an empty such as the !ollowing:
4.
Yes
5.
No
#he AND and "R logical operators can only be combined with the use o! parentheses.
6.
Yes
Additional *+A #or ,hapters 1-./ Oracle SQL by Example by Alice Rischert/ 0rentice 1all 223345 0age ) o# 16 7ersion8 )9292334
7.
Yes
8.
Yes
9.
No
,hapter "
1.
,haracter #unctions trans#orm data in tables in order to retrie=e it more easily. Yes No You can retrie=e speci#ic character data in a database regardless o# what case it was entered in. Yes No Arithmetic operators and number #unctions can be combined. No Yes %he D&A' table contains data trans#ormed by character #unctions. No Yes 'i(e character #unctionsC number #unctions operate on single =alues. Yes No %he '0AD #unction le#t trims a string. Yes No &nli(e many other character #unctionsC the ':NE%1 and ;NS%R #unction return a N&MB:R.
Additional *+A #or ,hapters 1-./ Oracle SQL by Example by Alice Rischert/ 0rentice 1all 223345 0age 6 o# 16 7ersion8 )9292334
2.
".
).
6.
..
No Yes
B.
%he #ollowing S*' >uery returns -18 S:':,% S;EN2-")5 <R$M dual Yes No You can substitute the N7' #unction with the ,$A':S,: #unction. No Yes %he simple ,AS: e?pression tests #or e>uality only. Yes No
4.
13 .
Note: All !unctions2 including character !unctions2 trans!orm the output o! data2 not actual data in tables. 0ou learn about modi!ying the data in tables in (hapter >>2 9)nsert2 $pdate2 and Delete.9
2. 3. 4. 5.
Yes
0ou can retrieve speci!ic character data in a database regardless o! what case it was entered in. Arithmetic operators and number !unctions can be combined.
Yes
No
Yes
6. 7. 8.
No
Yes
$nli&e many other character !unctions2 the %'N:#5 and )NS#R !unction return a N$MB'R. #he !ollowing S*% ,uery returns 8>: S'%'(# S):N?81@A +R"M dual
Yes
Additional *+A #or ,hapters 1-./ Oracle SQL by Example by Alice Rischert/ 0rentice 1all 223345 0age . o# 16 7ersion8 )9292334
9. 10.
Yes
0ou can substitute the N4% !unction with the ("A%'S(' !unction.
Yes
,hapter )
1.
%he #ollowing S*' >uery implicitly per#orms a data type con=ersion.
SELECT student_id, last_na e FROM student WHERE student_id = '!"#'
No Yes
2.
Dhich o# the #ollowing S*' statements results in this error8 $RA-31.228 in=alid number F
SELECT FROM SELECT FROM SELECT FROM SELECT FROM TO_CH(R'TO_$%M&ER'*+++,+++)) dual TO_CH(R'TO_$%M&ER''-*+++,+++')) dual TO_$%M&ER'TO_CH(R'+++,+++)) dual TO_CH(R'TO_$%M&ER''*+++,+++')) dual
".
Dhich #ormat mas( is re>uired to display this outputF !Mar 1.C 2313! Mon-dd yyyy Mon ddC yyyy dd-mon-yyyy M$N ddC YY
).
6.
..
No Yes
B.
No Yes
4.
%he #ollowing shows one o# the de#ault #ormats #or the %;M:S%AM0 D;%1 %;M: G$N: data type. !DD-M$N-RR 11.M;.SS.<< AM %G18%GM!. Yes No %he %$HDS;N%:R7A' #unction con=erts a te?t literal to an ;N%:R7A' DAY %$ S:,$ND data type. No Yes
13.
2.
3.
;hich o! the !ollowing S*% statements results in this error: "RA8 3>766: invalid number SELECT TO_CH(R'TO_$%M&ER''-*+++,+++')) FROM dual
A text literal such as E8FFF.FF cannot be converted into a number. $se the S$BS#R !unction to remove the E symbol2 and then convert to a number.
4. 5.
;hich !ollowing !ormat mas& is re,uired to display this outputD Mar >72 63>3 ;hich !ormat mas& is re,uired to display this outputD Sunday 6<>G<63>3
#he !illmode ?!mA speci!ier is re,uired be!ore the Day !ormat mas&. Note the case o! the !m speci!ier is irrelevant.
m!ay mm"dd"yyyy
6.
No
SELECT * FROM section WHERE start_date_ti e &ETWEE$ TO_.(TE''#!*.EC*""//','..*MO$ 0000') ($. TO_.(TE''/!1/!1!+//','MM1..10000')
#he B'#;''N operator re,uires the lowest end o! the range !irst2 then the highest. )nstead2 write it as !ollows:
7.
Yes
8.
No
SELECT course_no, odi4ied_date FROM section WHERE odi4ied_date 5=TO_.(TE''""*M(R*!+++', '..* MO$*0000') ($. odi4ied_date 2 TO_.(TE''"#*M(R*!+++', '..* MO$*0000')
9. 10.
Yes
#he !ollowing shows one o! the de!ault !ormats !or the #)M'S#AM/ ;)#5 #)M' H"N' data type. DD8M"N8RR 55.M).SS.++ AM #H5:#HM . #he #"BDS)N#'R4A% !unction converts a text literal to an )N#'R4A% DA0 #" S'("ND data type.
Yes
,hapter 6
1.
Aggregate #unctions always return a single result #or a group o# =alues. No Yes Aggregate #unctions usually ignore N&'' =alues. No Yes
2.
An aggregate #unction can be used in a 1A7;NE clause. Yes No %he 1A7;NE clause can be used instead o# the D1:R: clause. Yes No %he M;N and MAI #unctions wor( only on the N&MB:R data type. No Yes %he #ollowing >uery is in=alid.
SELECT (67'CO(LESCE'cost, /))
Additional *+A #or ,hapters 1-./ Oracle SQL by Example by Alice Rischert/ 0rentice 1all 223345 0age 11 o# 16 7ersion8 )9292334
".
).
6.
FROM course
Yes No
..
Yes No
Additional *+A #or ,hapters 1-./ Oracle SQL by Example by Alice Rischert/ 0rentice 1all 223345 0age 12 o# 16 7ersion8 )9292334
2.
Yes
3. 4. 5. 6.
Yes
Yes
No
#he M)N and MAI !unctions wor& only on the N$MB'R data type.
No
7.
SELECT S0S.(TE, 'HELLO', student_id, CO%$T'*) FROM enroll ent 7RO%8 &0 student_id
Additional *+A #or ,hapters 1-./ Oracle SQL by Example by Alice Rischert/ 0rentice 1all 223345 0age 1 o# 16 7ersion8 )9292334
,hapter .
1.
Dhich >uestion is answered by the #ollowing S*' statementF
SELECT FROM WHERE ($. ($. description, section_no, last_na e course c, section s, instructor i c,course_no = s,course_no s,instructor_id = i,instructor_id TO_CH(R'start_date_ti e, '.0') = 'T%E'
Show a list o# the coursesC sectionsC and instructors. Display the course descriptionC section numberC and the last name o# the instructor that teaches the section. Show only those courses with enrollments starting on %uesdays. Display a list o# course descriptionsC their section numbersC and #or each section the last name o# the assigned instructor. $nly show sections that start on %uesdays Display the course descriptionC section numberC and last names o# instructors teaching classes on Dednesdays. %he #ollowing two S*' statements are e>ui=alent.
SELECT FROM WHERE ($. SELECT FROM O$ WHERE s,student_id, e,section_id, s,last_na e student s, enroll ent e s,student_id = e,student_id last_na e = 'Torres' s,student_id, section_id, last_na e student s 3O9$ enroll ent e 's,student_id = e,student_id) last_na e = 'Torres'
2.
Yes No
Show the course description o# the course 3 in which the student with the id 221 is enrolled. Show also the grade type. Show the descriptionC grade typeC and grade #or course number 3 and the student with the id o# 221. ;n=alid >uery. %he S:':,% statement causes a ,artesian product.
Additional *+A #or ,hapters 1-./ Oracle SQL by Example by Alice Rischert/ 0rentice 1all 223345 0age 1" o# 16 7ersion8 )9292334
".
Show students with the #irst and last name o# %orres and their corresponding Jip code. ;nclude all the columns o# the G;0,$D: table in the result. ;n=alid >uery. Show the #irst and last name o# students with the last name o# %orres.
description, section_no, last_na e course c, section s, instructor i c,course_no = s,course_no s,instructor_id = i,instructor_id TO_CH(R'start_date_ti e, '.0') = 'T%E'
Display a list o! course descriptions2 their section numbers2 and !or each section the last name o! the assigned instructor. "nly show sections that start on #uesdays
2.
Yes
s,student_id, e,section_id, s,last_na e student s, enroll ent e s,student_id = e,student_id last_na e = 'Torres' s,student_id, section_id, last_na e student s 3O9$ enroll ent e 's,student_id = e,student_id) last_na e = 'Torres'
#he statements are e,uivalent. )t is pre!erable to speci!y aliases in the column2 because it is easier to identi!y which tables the columns belong to. )t also avoids any errors in S*% statements i! a column with the same name is added to the other table in the !uture.
3.
c,description, :rade_t;pe_code, nu eric_:rade :rade :, enroll ent e, section s, course c c,course_no = ##/ :,student_id = ""! s,course_no = c,course_no s,section_id = e,section_id :,section_id = e,section_id :,student_id = e,student_id
Additional *+A #or ,hapters 1-./ Oracle SQL by Example by Alice Rischert/ 0rentice 1all 223345 0age 1) o# 16 7ersion8 )9292334
Show the description2 grade type2 and grade !or course number CC3 and the student with the id o! 66>.
4.
Show the !irst and last name o! students with the last name o! #orres and their corresponding Jip code. )nclude all the columns o! the H)/("D' table in the result.
<,*, last_na e, 4irst_na e student s 3O9$ <ipcode < 's,<ip = <,<ip) last_na e = 'Torres'
Additional *+A #or ,hapters 1-./ Oracle SQL by Example by Alice Rischert/ 0rentice 1all 223345 0age 16 o# 16 7ersion8 )9292334