20605017 SQL Model Questions

Embed Size (px)

Citation preview

  • 8/13/2019 20605017 SQL Model Questions

    1/17

    Question: 1.Which SELECT statement should you use if you want to display unique combinations of thePOSITION and M N !E" #alues f$om the EMPLO%EE table&

    ' SELECT (ISTINCT position) mana*e$ +"OM employee,-' SELECT position) mana*e$ (ISTINCT+"OM employee,C' SELECT position) mana*e$ +"OM employee,(' SELECT position) (ISTINCT mana*e$ +"OM employee,

    Question: 2Which is an .S/L0Plus command&

    ' INSE"T-' 1P( TEC' SELECT(' (ESC"I-EE' (ELETE+' "EN ME

    Question: 3.%ou need to p$oduce a $epo$t fo$ mailin* labels fo$ all custome$s' The mailin* label must ha#eonly the custome$ name and add$ess' The C1STOME"S table has these columns2

    C1ST3I( N1M-E"456 NOT N1LLC1ST3N ME 7 "C8 "94:;;6C1ST3 (("ESS 7 "C8 "94:ecuted on the client side'E' The O"(E" -% clause comes last in the SELECT statement'+' The O"(E" -% clause is e>ecuted fi$st in the que$y e>ecution

  • 8/13/2019 20605017 SQL Model Questions

    2/17

    Question: 5.Which S/L SELECT statements pe$fo$ms a p$o?ection) a selection) and ?oin when e>ecuted&

    ' SELECT p'id3numbe$) m'manufactu$e$3id) m'city+"OM p$oduct p) manufactu$e$ mW8E"E p'manufactu$e$3id @ m'manufactu$e$3id

    N( m'manufactu$e$3id @ AN+:;;B9A,

    -' SELECT id3numbe$) manufactu$e$3id+"OM p$oductO"(E" -% manufactu$e$3id) id3numbe$,

    C' SELECT id3numbe$) manufactu$e$3id+"OM p$oductW8E"E manufactu$e$3id @ AN+:;;B9A,

    (' SELECT manufactu$e$3id) city+"OM manufactu$e$

    N( manufactu$e$3id @ AN+:;;B9AO"(E" -% city

    Question: 6.The C1STOME"S table has these columns2C1STOME"3I( N1M-E"456 NOT N1LLC1STOME"3N ME 7 "C8 "94:;;6 NOT N1LLST"EET3 (("ESS 7 "C8 "94:

  • 8/13/2019 20605017 SQL Model Questions

    3/17

    Question: 7.E#aluate these two S/L statements2SELECT last3name) sala$y ) hi$e3date

    +"OM EMPLO%EESO"(E" -% sala$y (ESC,

    SELECT last3name) sala$y) hi$e3date+"OM EMPLO%EESO"(E" -% 9 (ESC,

    What is t$ue about them& ' The two statements p$oduce identical $esults'-' The second statement $etu$ns a synta> e$$o$'C' The$e is no need to specify (ESC because the $esults a$e so$ted in descendin* o$de$ bydefault'(' The two statements can be made to p$oduce identical $esults by addin* a column alias fo$ thesala$y column in the second S/L statement

    Question: 7.%ou a$e fo$mulatin* que$ies in a S/L0Plus' Which of the followin* statement co$$ectly desc$ibeshow to specify a column alias&

    ' Place the alias at the be*innin* of the statement to desc$ibe the table'-' Place the alias afte$ each column sepa$ated by a space to desc$ibe the column'C' Place the alias afte$ each column sepa$ated by a comma to desc$ibe the column'(' Place the alias at the end of the statement to desc$ibe the table'

    Question: 8.%ou want to use a function in you column clause of a S/L statement' The N7L functionaccomplishes which of the followin* tas=s&

    ' ssists in the dist$ibution of output ac$oss multiple columns'-' Enables you to specify alte$nate output fo$ non N1LL column #alues'C' Enables you to specify alte$nated out fo$ N1LL column #alues'(' Nullifies the #alue of the column out put'

    Question:9.%ou need to display the last names of those employees who ha#e the lette$ D as the secondcha$acte$ in thei$ names'

    Which S/L statement displays the $equi$ed $esults& ' SELECT last3name+"OM EMPW8E"E last3name LIFE G3 H ,

    -' SELECT last3name+"OM EMPW8E"E last name @ 0 H

  • 8/13/2019 20605017 SQL Model Questions

    4/17

    C' SELECT last3name+"OM EMPW8E"E last name @ 3 H ,(' SELECT last3name+"OM EMPW8E"E last name LIFE G0 H

    Question:10.%ou want to display the titles of boo=s that meet these c$ite$ia2:' Pu$chased befo$e Janua$y 9:) 9;;:9' P$ice is less then K

  • 8/13/2019 20605017 SQL Model Questions

    5/17

    ' SELECT TO3( TE4S%S( TE) A+M( %) (( Month) %%%%A6+"OM dual,

    -' SELECT TO3C8 "4S%S( TE) A+M(() (% Month) A%%%A6+"OM dual,C' SELECT TO3C8 "4S%S( TE) A+M(ay) (( Month) %%%%A6+"OM dual,

    (' SELECT TO3C8 "4S%S( TE) A+M(%) ((( Month) %%%%A6+"OM dual,

    E' SELECT TO3( TE4S%S( TE) A+M(%) ((( Month) %%%%A6+"OM dual,

    Question:13:B' Evaluate the SQL statement:

    SELECT ROUND(45.953, - !, TRUNC(45.93", #!

    $RO% &ual'h)*h values a+e &)s la e&

    /. 4" an& 450. 4" an& 45.93C. 51 an& 45.93D. 51 an& 45.9E. 45 an& 45.93$. 45.95 an& 45.93

    Question:14. E>amine the desc$iption of the EMPLO%EES table2

    Which statement shows the depa$tment I() minimum sala$y) and ma>imum sala$y paid in thatdepa$tment) only of the minimum sala$y is less then imum sala$y is mo$e than:

  • 8/13/2019 20605017 SQL Model Questions

    6/17

    -' SELECT dept3id) MIN4sala$y6) M 4sala$y6+"OM employeesW8E"E MIN4sala$y6

  • 8/13/2019 20605017 SQL Model Questions

    7/17

    E>amine the st$uctu$e of the EMPLO%EES and NEW3EMPLO%EES tables2

    EMPLO%EES2EMPLO%EE3I( N1M-E" P$ima$y Fey+I"ST3N ME 7 "C8 "9 49

  • 8/13/2019 20605017 SQL Model Questions

    8/17

    Question:19

    Which fou$ a$e co$$ect *uidelines fo$ namin* database tables& 4Choose fou$6 ' Must be*in with eithe$ a numbe$ o$ a lette$'-' Must be : B; cha$acte$s lon*'C' Should not be an O$acle Se$#e$ $ese$#ed wo$d'(' Must contain only ) a ) ; U) 3) 0) and V'E' Must contain only ) a ) ; ) 3) K) and V'+' Must be*in with a lette$'

    Question:20E>amine the st$uctu$e of the EMPLO%EES table2Column name (ata type "ema$=s

    EMPLO%EE3I( N1M-E" NOT N1LL) P$ima$y FeyL ST3N ME 7 "CN "94B;6+I"ST3N ME 7 "CN "94B;6JO-3I( N1M-E"S L N1M-E"M!"3I( N1M-E" "efe$ences EMPLO%EE3I( column(EP "TMENT3I( N1M-E"

    %ou need to c$eate an inde> called N ME3I( on the fi$st name and last name fields of theEMPLO%EES table' Which S/L statement would you use to pe$fo$m this tas=&

    ' C"E TE IN(E N ME3I( 4fi$st3name) last3name6,

    -' C"E TE IN(E N ME3I( 4fi$st3name N( last3name6,

    C' C"E TE IN(E N ME3I(ON 4fi$st3name) last3name6,

    (' C"E TE IN(E N ME3I(ON employees 4fi$st3name N( last3name6,

    E' C"E TE IN(E N ME3I(ON employees4fi$st3name) last3name6,

    +' C"E TE IN(E N ME3I(+O" employees4fi$st3name) last3name6,

    Question: 21E>amine the st$uctu$e of the EMPLO%EE table'EMPLOYEE Table

    EMPLO%EE3I( N1M-E" NOT N1LL) P$ima$y FeyEMP3LN ME 7 "C8 "9 49

  • 8/13/2019 20605017 SQL Model Questions

    9/17

    cu$$ently contains B;;; $eco$ds& ' %ou C NNOT inc$ease the width of the EMP3LN ME column'-' LTE" T -LE employeeMO(I+% emp3lname 7 "C8 "949ists in use$ !$e*As schema'-' The C1STOME" table was c$eated in the (- schema'C' The C1STOME" table was c$eated in the public schema'(' The C1STOME" table is accessible to all use$s'

    Question: 23

    E>amine the st$uctu$e of the P"O(1CT table'

    P"O(1CT3I( N1M-E" NOT N1LL) P$ima$y FeyP"O(1CT3N ME 7 "C8 "9 49

  • 8/13/2019 20605017 SQL Model Questions

    10/17

    "EPL CE COL1MN 4list3p$ice N1M-E"4R)96,

    E' %ou C NNOT $educe the si e of the LIST3P"ICE column'

    Question: 24%ou need to chan*e the definition of an e>istin* table' The COMME"CI LS table needs its(ESC"IPTION column chan*ed to hold #a$yin* len*th cha$acte$s up to 9;;; bytes' The columncan cu$$ently hold :;;; bytes pe$ #alue' The table contains 9;;;; $ows'Which statement is #alid&

    ' LTE" T -LE comme$cialsMO(I+% 4desc$iption C8 "949;;;66,-' LTE" T -LE comme$cialsC8 N!E 4desc$iption C8 "949;;;66,C' LTE" T -LE comme$cialsC8 N!E 4desc$iption 7 "C8 "949;;;66,(' LTE" T -LE comme$cialsMO(I+% 4desc$iption 7 "C8 "949;;;66,E' %ou cannot inc$ease the si e of a column if the table has $ows

    Question: 25

    Which S/L statement defines the +O"EI!N FE% const$aint on the (EPTNO columnof the EMP table&

    ' C"E TE T -LE EMP4empno N1M-E"456)ename 7 "CN "94B

  • 8/13/2019 20605017 SQL Model Questions

    11/17

  • 8/13/2019 20605017 SQL Model Questions

    12/17

    %ou maintain two tables) C1STOME" and P"OSPECT) that ha#e identical st$uctu$es butdiffe$ent data' %ou want to synch$oni e these two tables by inse$tin* $eco$ds f$om theP"OSPECT table into the C1STOME" table) if they do not e>ist' If the custome$ al$eady e>ists inthe C1STOME" table) you want to update custome$ data'

    Which (ML statement should you use to pe$fo$m this tas=& ' INSE"T-' 1P( TEC' S%NC(' ME"!EE' %ou C NNOT pe$fo$m this tas= with one (ML ope$ation

    Question: 29

    E>amine the st$uctu$e of the EMPLO%EES table2

    EMPLO%EE3I( N1M-E" P$ima$y Fey+I"ST3N ME 7 "CN "949

  • 8/13/2019 20605017 SQL Model Questions

    13/17

    8ow can you accomplish this tas=& ' LTE" 7IEW emp3dept3#u 4 (( mana*e$3id N1M-E"6,

    -' MO(I+% 7IEW emp3dept3#u 4 (( mana*e$3id N1M-E"6,

    C' LTE" 7IEW emp3dept3#u SSELECT employee3id) employee3name)depa$tment3name) mana*e$3id+"OM employee e) depa$tments dW8E"E e'depa$tment3id @ d'depa$tment3id,

    (' MO(I+% 7IEW emp3dept3#u SSELECT employee3id) employee3name)depa$tment3name) mana*e$3id+"OM employees e) depa$tments dW8E"E e'depa$tment3id @ d'depa$tment3id,

    E' C"E TE O" "EPL CE 7IEW emp3dept3#u SSELECT employee3id) employee3name)depa$tment3name) mana*e$3id+"OM employees e) depa$tments dW8E"E e'depa$tment3id @ d'depa$tment3id,

    +' %ou must $emo#e the e>istin* #iew fi$st) and then $un the C"E TE 7IEW command with anew column list to modify a #iew'

    Question: 31

    Lo**ed on as use$ nn) you issue these S/L statements2

    C"E TE T -LE custome$ 4custome$3id N1M-E")company3id 7 "C8 "94B;6)contact3name 7 "C8 "94B;6)contact3title 7 "C8 "949;6)add$ess 7 "C8 "94B;6)city 7 "C8 "949

  • 8/13/2019 20605017 SQL Model Questions

    14/17

    ' SELECT 0 +"OM ann'custome$,-' SELECT custome$3id +"OM custome$,C' SELECT custome$3name) phone +"OM cust,(' SELECT 0 +"OM ann'cust,E' SELECT CO1NT4city6 +"OM chan'cust

    Question: 32E>amine the st$uctu$e of the P"O(1CT table'

    P"O(1CT3I( N1M-E" NOT N1LL) P$ima$y FeyP"O(1CT3N ME 7 "C8 "9 49amine the st$uctu$e of the C1""3O"(E" table as shown below2

    !""#O"$E" TableO"(E"3I( N1M-E" NOT N1LL) P$ima$y Fey

    C1STOME"3I( N1M-E" NOT N1LL) +o$ei*n Fey to C1STOME"3I(column of the C1STOME"S tableEMP3I( N1M-E" NOT N1LL) +o$ei*n Fey to EMP3I( column of the EMPLO%EES tableO"(E"3(T ( TE NOT N1LLO"(E"3 MT N1M-E" 4 )96S8IP3MET8O( 7 "C8 "9 4

  • 8/13/2019 20605017 SQL Model Questions

    15/17

    C"E TE 7IEW statement included the WIT8 C8ECF OPTION clause'Which statement will e>ecute successfully&

    ' INSE"T INTO o$de$3# 4o$de$3id) custome$3id) emp3id) o$de$3dt) o$de$3amt67 L1ES 4X5;) 9 9) :;5) A:; OCT 9;;:A) B:X6,

    -' INSE"T INTO o$de$3# 4o$de$3id) custome$3id) emp3id) o$de$3amt) ship3method67 L1ES 4 BR) 9 9) :;5) 9

  • 8/13/2019 20605017 SQL Model Questions

    16/17

    What p$i#ile*es does the use$ Scott ha#e at this point& ' No p$i#ile*es'-' Only the SELECT p$i#ile*e'C' Only the CONNECT p$i#ile*e'(' ll the p$i#ile*es of a default use$

    Question: 37Which p$i#ile*e is an ob?ect p$i#ile*e&

    ' IN(E-' ("OP 1SE"C' C"E TE SESSION(' - CF1P N% T -LE

    Question: 38E>amine the st$uctu$e of the EMP3(EPT371 #iew2

    Column Name Type "ema$=s

    EMPLO%EE3I( N1M-E" +$om the EMPLO%EES table EMP3N ME 7 "C8 "94B;6 +$om the EMPLO%EES tableJO-3I( 7 "C8 "949;6 +$om the EMPLO%EES tableS L "% N1M-E" +$om the EMPLO%EES table

    (EP "TMENT3I( N1M-E" +$om the (EP "TMENTS table(EPT3N ME 7 "C8 "94B;6 +$om the (EP "TMENTS table

    Which S/L statement p$oduces an e$$o$&

    ' SELECT 0 +"OM emp3dept3#u,

    -' SELECT depa$tment3id) S1M4sala$y6 +"OM emp3dept3#u !"O1P -% depa$tment3id,

    C' SELECT depa$tment3id) ?ob3id) 7!4sala$y6 +"OM emp3dept3#u !"O1P -%depa$tment3id) ?ob3id,

    (' SELECT ?ob3id) S1M4sala$y6 +"OM emp3dept3#u W8E"E depa$tment3id IN 4:;)9;6!"O1P -% ?ob3id 8 7IN! S1M4sala$y6 9;;;;,

    E' None of the statements p$oduce an e$$o$, all a$e #alid'

    Question:39

    Which const$aint can be defined only at the column le#el&

    ' 1NI/1E-' NOT N1LLC' C8ECF(' P"IM "% FE%

  • 8/13/2019 20605017 SQL Model Questions

    17/17

    E' +O"EI!N FE%

    Question:40%Which two statements about subque$ies a$e t$ue& 4Choose two'6

    ' subque$y should $et$ie#e only one $ow'-' subque$y can $et$ie#e e$o o$ mo$e $ows'C' subque$y can be used only in S/L que$y statements'(' Subque$ies C NNOT be nested by mo$e than two le#els'E' subque$y C NNOT be used in an S/L que$y statement that uses *$oup functions'+' When a subque$y is used with an inequality compa$ison ope$ato$ in the oute$ S/L statement)the column list in the SELECT clause of the subque$y should contain only one column'