版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
ViewtheExhibitandexaminethestructureoftheSALES,CUSTOMERS,PRODUCTS,andTIMESThePROD_IDcolumnistheforeignkeyintheSALEStable,whichreferencesthePRODUCTStable.Similarly,theCUST_IDandTIME_IDcolumnsarealsoforeignkeysintheSALEStablereferencingtheCUSTOMERSandTIMEStables,respectively.EvaluatethefollowingCREATETABLEcommand:CREATETABLEnew_sales(prod_id,cust_id,order_dateDEFAULTSYSDATE)SELECTprod_id,cust_id,time_idFROMsales;WhichstatementistrueregardingtheaboveTheNEW_SALEStablewouldnotgetcreatedbecausetheDEFAULTvaluecannotbespecifiedinthecolumnTheNEW_SALEStablewouldgetcreatedandalltheNOTNULLconstraintsdefinedonthespecifiedcolumnswouldbepassedtothenewTheNEW_SALEStablewouldnotgetcreatedbecausethecolumnnamesintheCREATETABLEcommandandtheSELECTclausedonotTheNEW_SALEStablewouldgetcreatedandalltheFOREIGNKEYconstraintsdefinedonthespecifiedcolumnswouldbepassedtothenewAnswer:CREATETABLEnew_sales(prod_id,cust_id,order_dateDEFAULTSYSDATE)SELECTprod_id,cust_id,time_idFROMsales;salescreatetablezbcxyidnumber(20)notsnonumber(10)char(2)check(in('男','女')),cnonumber(6)referencescreatetablezbdbaselect*from notnull char(2) ViewtheExhibittoexaminethedescriptionfortheSALESWhichviewscanhaveallDMLoperationsperformedonit?(ChooseallthatCREATEVIEWASSELECT*FROMWHEREcust_id=2034WITHCHECKCREATEVIEWASSELECT*FROMSALESWHEREtime_id<=SYSDATE-2*365WITHCHECKOPTION;CREATEVIEWASSELECTprod_id,cust_id,time_idFROMSALESWHEREtime_id<=SYSDATE-2*365WITHCHECKCREATEVIEWASSELECTprod_id,cust_id,SUM(ty_sold)FROMWHEREtime_id<=SYSDATE-GROUPBYprod_id,cust_idWITHCHECKOPTION;Answer:dmlcdc和dsalesinsert操作,即withcheckoptionsales表所有属性列都是为非空的withcheckoption就是对视图操作的一个条件限制,条件就是创建视图时B选项,则对视图做更新操作时,time_id是不能>sysdate-2*365YouneedtoextractdetailsofthoseproductsintheSALEStablewherethePROD_IDcontainstheWhichWHEREclausecouldbeusedintheSELECTstatementtogettherequiredWHEREprod_idLIKE'%_D123%'ESCAPEWHEREprod_idLIKE'%\_D123%'ESCAPEWHEREprod_idLIKE'%_D123%'ESCAPEWHEREprod_idLIKE'%\_D123%'ESCAPEAnswer:如果要查询的信息本身包含”%”或”_”,ESCAPESelect*fromempwhereenamelike‘’%x_%’escapeWhichtwostatementsaretrueregardingsinglerowfunctions?(ChooseTheyacceptonlyasingleTheycanbenestedonlytotwoArgumentscanonlybecolumnvaluesorTheyalwaysreturnasingleresultrowforeveryrowofaqueriedTheycanreturnadatatypevaluedifferentfromtheonethatisAnswer:oracle文档sqlreference中对Single-rowfunctions的解释Single-rowfunctionsreturnasingleresultrowforeveryrowofaqueriedtableorview.Thesefunctionscanappearinselectlists,WHEREclauses,STARTWITHandCONNECTBYclauses,andHAVINGclausesATAN2(m,n),a选项错误numberDEWhichSQLstatementswoulddisythevalue1890.55as$1,890.55?(Choosethree.)FROMDUAL;FROMDUAL;FROMDUAL;FROMDUAL;FROMDUAL;Answer:222FROMDUAL;*1行出现错误ORA-01481:22G代表逗号,DVTO_CHAR(N,'999V9'),pV的位置,则该表达式=to_char(N×(10P-1次方)).9个数又必须保证大于等于乘积之后表示的位数.ExaminethestructureoftheSHIPMENTSnameNullPO_IDNOTNULLNUMBER(3)PO_DATENOTNULLDATESHIPMENT_DATENOTNULLDATEYouwanttogenerateareportthatdisysthePO_IDandthepenaltyamounttobepaidiftheSHIPMENT_DATEislaterthanonemonthfromthePO_DATE.Thepenaltyis$20perEvaluatethefollowinoSQL>SELECTWHENMONTHS_BETWEEN(shipment_date,po_date)>1THENTO_CHAR((shipment_date-po_date)*20)ELSE'NoPenalty'ENDPENALTYFROMshipments;SQL>SELECTTO_CHAR((shipment_date-po_date)*20),'NoPenalty')PENALTYFROMshipments;WhichstatementistrueregardingtheaboveBothexecutesuccessfullyandgivecorrectOnlythefirstqueryexecutessuccessfullybutgivesawrongOnlythefirstqueryexecutessuccessfullyandgivesthecorrectOnlythesecondqueryexecutessuccessfullybutgivesawrongOnlythesecondqueryexecutessuccessfullyandgivesthecorrectAnswer:caseexpressionswhichletyouuseIFTHENELSElogicinSQLstatementswithouthavingtoDECODEcomparesexprtoeachsearchvalueonebyone.Ifexprisequaltoasearch,thenOracleDatabasereturnsthecorrespondingresult.Ifnomatchisfound,thenOraclereturnsdefault.Ifdefaultisomitted,thenOraclereturnsnull.Theargumentscanbeanyofthenumerictypes(NUMBER,BINARY_FLOAT,orBINARY_DOUBLE)orcharactertypes.WhichtwostatementsaretrueregardingtheUSINGandONclausesintablejoins?(Choosetwo.)BothUSINGandONclausescanbeusedforequijoinsandAumofonepairofcolumnscanbejoinedbetweentwotablesusingtheONTheONclausecanbeusedtojointablesoncolumnsthathavedifferentnamesbutcompatibledataTheWHEREclausecanbeusedtoapplyadditionalconditionsinSELECTstatementscontainingtheONortheUSINGAnswer:ONcondition UsetheONclausetospecifyajoincondition.ngsoletsyouspecifyjoinconditionsseparatefromanysearchorfilterconditionsintheWHEREclause.USING(column) Whenyouarespecifyinganequijoinofcolumnsthathavethesamenameinbothtables,theUSINGcolumnclauseindicatesthecolumnstobeused.Youcanusethisclauseonlyifthejoincolumnsinbothtableshavethesamename.Withinthisclause,donotqualifythecolumnnamewithatablenameortablealias.ViewtheExhibitandexaminethestructureoftheCUSTOMERSWhichtwotaskswouldrequiresubqueriesorjoinstobeexecutedinasinglestatement?(Choosetwo.)listingofcustomerswhodonothaveacreditlimitandwerebornbeforefindingthenumberofcustomers,ineachcity,whosemaritalstatusisfindingtheaveragecreditlimitofmalecustomersresidingin'Tokyo'orlistingofthosecustomerswhosecreditlimitisthesameasthecreditlimitofcustomersresidinginthecityfindingthenumberofcustomers,ineachcity,whosecreditlimitismorethantheaveragecreditlimitofalltheAnswer:joinWhichstatementistrueregardingtheINTERSECTItignoresReversingtheorderoftheintersectedtablesalterstheThenamesofcolumnsinallSELECTstatementsmustbeThenumberofcolumnsanddatatypesmustbeidenticalforallSELECTstatementsinthequery.Answer:insertDViewtheExhibit;examinethestructureofthePROMOTIONSEachpromotionhasadurationofatleastsevendaysYourmanagerhasaskedyoutogenerateareport,whichprovidestheweeklycostforeachpromotiondonetolWhichquerywouldachievetherequiredSELECTpromo_name,promo_cost/promo_end_date-promo_begin_date/7FROMpromotions;FROMpromotions;SELECTpromo_name,promo_cost/(promo_end_date-promo_begin_date/7)FROMpromotions;SELECTpromo_name,promo_cost/((promo_end_date-promo_begin_date)/7)FROMpromotions;Answer:7ViewtheExhibitandexaminethestructureofthePRODUCTSAllproductshaveaYouissuethe mandtodisythetotalpriceofeachproductafteradiscountof25%andataxof15%areappliedonit.Freightchargesof$100havetobeappliedtoalltheAS"TOTALPRICE"FROMWhatwouldbe eifalltheparenthesesareremovedfromtheaboveItproducesaTheresultThetotalpricevaluewouldbelowerthanthecorrectThetotalpricevaluewouldbehigherthanthecorrectAnswer:Youneedtoproduceareportwhereeachcustomer'screditlimithasbeenincrementedby$1000.Intheoutput,thecustomer'slastnameshouldhavetheheadingNameandtheincrementedcreditlimitshouldbelabeledNewCreditLimit.ThecolumnheadingsshouldhaveonlythefirstletterofeachwordinuppercaseWhich plishthisSELECTcust_last_nameName,cust_credit_limit+1000"NewCreditLimit"FROMSELECTcust_last_nameASName,cust_credit_limit+1000ASNewCreditLimitFROMSELECTcust_last_nameAS"Name",cust_credit_limit+1000AS"NewCreditLimit"FROMSELECTINITCAP(cust_last_name)"Name",cust_credit_limit+1000INITCAP("NEWCREDITLIMIT")FROMAnswer:scott@ORCL>selectename "NewCreditLitmit"from NewCreditscott@ORCL>selectenameas as"NewCreditLimit"from NewCreditasscott@ORCL>selectename "NewCreditLitmit"from NewCreditViewtheExhibitandexaminethestructureofthePRODUCTSYouneedtogenerateareportinthefollowingformat:5MPDigitalPhotoCamera'scategoryisPhotoYBox'scategoryisElectronicsEnvoyAmbassador'scategoryisWhichtwoquerieswouldgivetherequiredoutput?(ChooseSELECTprod_name||q''||'scategoryis'||prod_categoryFROMSELECTprod_name||q'['s]||'categoryis'||prod_categoryCATEGORIESFROMproducts;SELECTprod_name||q'\'s\'||'categoryis'||prod_categoryCATEGORIESFROMproducts;SELECTprod_name||q'<'s>'||'categoryis'||prod_categoryCATEGORIESFROMproducts;Answer:scott@ORCL>selectename||q'\'s\'||'categoryis'||salfromSMITH'scategoryisALLEN'scategoryisscott@ORCL>selectename||q'<'s>'||'categoryis'||salfromSMITH'scategoryisUsingtheCUSTOMERStable,youneedtogenerateareportthatshows50%ofeachamountineach elevel.ThereportshouldNOTshowanyrepeatedcreditamountsineach Whichquerywouldgivetherequirede_level,DISTINCTcust_credit_limit*0.50AS"50%CreditLimit"FROM e_level,DISTINCTcust_credit_limit*0.50AS"50%CreditLimit"FROM e_level||''||cust_credit_limit*0.50AS"50%CreditLimit"e_level''cust_credit_limit*0.50AS"50%CreditLimit"Answer:解析:主要dictinct的应用,去除重复ViewtheExhibitandexaminethedataintheCUSTOMERSEvaluatetheSQL>SELECTcust_nameAS"NAME",cust_credit_limit/2ASMIDPOINT,MIDPOINT+100AS"MAXLOWERFROMTheabovequeryproducesanerroronexecution.Whatisthereasonfortheerror?AnaliascannotbeusedinanThealiasNAMEshouldnotbeenclosedwithindoublequotationmarksTheMIDPOINT+100expressiongivesanerrorbecauseCUST_CREDIT_LIMITcontainsNULLThealiasMIDPOINTshouldbeenclosedwithindoublequotationmarksfortheCUST_CREDIT_LIMIT/2expression.Answer:EvaluatethefollowingSQL>SELECTpromo_name||q'{'sstartdatewas}'||promo_begin_dateAS"PromotionLaunches"FROMWhatwould eoftheaboveItproducesanerrorbecauseflowerbraceshavebeenItproducesanerrorbecausethedatatypesarenotItexecutessuccessfullyandintroducesan'sattheendofeachpromo_nameintheItexecutessuccessfullyanddisysthelil"{'sstartdatewas}"foreachrowintheoutput.Answer:scott@ORCL>SELECTename||q'{'sstartdatewas}'||AS"PromotionPromotionSMITH'sstartdatewas17-12月-80ALLEN'sstartdatewas20-2月-81WARD'sstartdatewas22-2月-81JONES'sstartdatewas02-4月-81MARTIN'sstartdatewas28-9月-81BLAKE'sstartdatewas01-5月-81CLARK'sstartdatewas09-6月-81SCOTT'sstartdatewas19-4月-87KING'sstartdatewas17-11月-81TURNER'sstartdatewas08-9-81ADAMS'sstartdatewas23-5月-87JAMES'sstartdatewas03-12月-81FORD'sstartdatewas03-12月-81MILLER'sstartdatewas23-1月-82ViewtheExhibitandexaminethedataintheEMPLOYEESYouwanttogenerateareportshowingthetotalcompensationpaidtoeachemployeetoYouissuetheSQL>SELECTename||'joinedon'||hiredate||',the pensationpaidis'||TO_CHAR(ROUND(ROUND(SYSDATE-hiredate)/365)*sal+comm)"COMPENSATIONUNTILDATE"FROMWhatis ItgeneratesanerrorbecausethealiasisnotItexecutessuccessfullyandgivesthecorrectItexecutessuccessfullybutdoesnotgivethecorrectItgeneratesanerrorbecausetheusageoftheROUNDfunctionintheexpressionisnotvalid.Itgeneratesanerrorbecausetheconcatenationoperatorcanbeusedtocombineonlytwoitems.Answer:scott@ORCL>SELECTename||'joinedon'||hiredate',thetotalcompensationpaidis'TO_CHAR(ROUND(ROUND(SYSDATE-hiredate)/365)*sal+"COMPENSATIONUNTILCOMPENSATIONUNTILSMITHjoinedon17-12月-80,thetotalcompensationpaidisALLENjoinedon20-2-81thetotalcompensationpaidis52960WARDjoinedon22-2月-81thetotalcompensationpaidis41750JONESjoinedon02-4月-81,thetotalcompensationpaidisMARTINjoinedon28-9-81thetotalcompensationpaidis41400BLAKEjoinedon01-5月-81,thetotalcompensationpaidisCLARKjoinedon09-6-81thetotalcompensationpaidisSCOTTjoinedon19-4-87thetotalcompensationpaidisKINGjoinedon17-11月-81,thetotalcompensationpaidisTURNERjoinedon08-9-81thetotalcompensationpaidis48000ADAMSjoinedon23-5月-87,thetotalcompensationpaidisJAMESjoinedon03-12月-81,thetotalcompensationpaidisFORDjoinedon03-12月-81,thetotalcompensationpaidisMILLERjoinedon23-1-82thetotalcompensationpaidis14 mfromempwhereMoraclescott@ORCL>select1000+nvl(comm,0)fromempwhereExaminethestructureofthePROMOTIONStable:nameNullTypePROMO_IDNOTNULLNUMBER(6)PROMO_NAMENOTNULLVARCHAR2(30)PROMO_CATEGORYNOTNULLVARCHAR2(30)PROMO_COSTNOTNULLNUMBER(10,2)ThemanagementwantstoseeareportofuniquepromotioncostsineachpromotionWhichquerywouldachievetherequiredSELECTDISTINCTpromo_cost,promo_categoryFROMSELECTpromo_category,DISTINCTpromo_costFROMSELECTDISTINCTpromo_cost,DISTINCTpromo_categoryFROMSELECTDISTINCTpromo_category,promo_costFROMpromotionsORDERBYAnswer:解析:distinct后的字段顺序不同,得到的结果顺序也不同,但是最终的内容都是一样的,ADorderby1的区别,下面我们看看它的作用:scott@ORCL>selectdistinctjob,salfrom 630012行。scott@ORCL>selectdistinctjob,salfromemporderby 12DEvaluatethefollowingSELECTINTERVAL'300'MONTH,INTERVAL'54-2'YEARTOMONTH, 'HOURTOFROMWhatisthecorrectoutputoftheaboveA.+25-00,+54- ,+54- C.+25-00 ,+00Answer:INTERVAL'54-2'YEARTOINTERVAL 'HOURTO +00INTERVALYEARTOMONTHDataINTERVALYEARTOMONTHstoresaperiodoftimeusingtheYEARandMONTHdatetimefields.Thisdatatypeisusefulforrepresentingthedifferencebetweentwodatetimevalueswhenonlytheyearandmonthvaluesaresignificant.SpecifyINTERVALYEARTOMONTHasINTERVALYEAR[(year_precision)]TOwhereyear_precisionisthenumberofdigitsintheYEARdatetimefield.Thedefaultvalueofyear_precisionis2.MONTH2300YEARTOMONTH于是206123457WhichthreestatementsaretrueregardingthedatatypesinOracleDatabaseOnlyoneLONGcolumncanbeusedperATIMESTAMPdatatypecolumnstoresonlytimevalueswithfractionalTheBLOBdatatypecolumnisusedtostorebinarydatainanoperatingsystemTheminimumcolumnwidththatcanbespecifiedforaVARCHAR2datatypecolumnisThevalueforaCHARdatatypecolumnisblank-paddedtotheumdefinedcolumnwidth.Answer:oracle文档:TheuseofLONGvaluesissubjecttotheseAtablecancontainonlyoneLONGYoucannotcreateanobjecttypewithaLONGLONGcolumnscannotappearinWHEREclausesorinintegrityconstraints(exceptthattheycanappearinNULLandNOTNULLconstraints).TheTIMESTAMPdatatypeisanextensionoftheDATEdatatype.Itstorestheyear,month,anddayoftheDATEdatatype,plushour,minute,andsecondvalues.Thisdatatypeisusefulforstoringprecisetimevaluesandforcollectingandevaluatingdateinformationacrossgeographicregions.TheBLOBdatatypestoresunstructuredbinarylargeobjects.BLOBobjectscanbethoughtofasbitstreamswithnocharactersetsemantics.BLOBobjectscanstorebinarydataupto(4gigabytes-1)*(thevalueoftheCHUNKparameterofLOBstorage).Ifthetablespacesinyourdatabaseareofstandardblocksize,andifyouhaveusedthedefaultvalueoftheCHUNKparameterofLOBstoragewhencreatingaLOBcolumn,thenthisisequivalentto(4gigabytes-1)*(databaseblocksize).TheVARCHAR2datatypespecifiesavariable-lengthcharacterstring.WhenyoucreateaVARCHAR2column,yousupplytheumnumberofbytesorcharactersofdatathatitcanhold.Oraclesubsequentlystoreseachvalueinthecolumnexactlyasyouspecifyit,providedthevaluedoesnotexceedtheumlengthofthecolumn.Ifyoutrytoinsertavaluethatexceedsthespecifiedlength,thenOraclereturnsanerrorTheCHARdatatypespecifiesafixed-lengthcharacterstring.OracleensuresthatallvaluesstoredinaCHARcolumnhavethelengthspecifiedbysize.Ifyouinsertavaluethatisshorterthanthecolumnlength,thenOracleblank-padsthevaluetocolumnlength.Ifyoutrytoinsertavaluethatistoolongforthecolumn,thenOraclereturnsanerror.ExaminethedescriptionoftheEMP_DETAILStablegivenbelow:nameNULLTYPEEMP_IDNOTNULLNUMBEREMP_NAMENOTNULLVARCHAR2(40)EMP_IMAGELONGWhichtwostatementsaretrueregardingSQLstatementsthatcanbeexecutedonthetable?(ChooseAnEMP_IMAGEcolumncanbeincludedintheGROUPBYAnEMP_IMAGEcolumncannotbeincludedintheORDERBYYoucannotaddanewcolumntothetablewithLONGasthedataYoucanalterthetabletoincludetheNOTNULLconstraintontheEMP_IMAGEAnswer:oracle文档:Inaddition,LONGcolumnscannotappearinthesepartsofSQLGROUPBYclauses,ORDERBYclauses,orCONNECTBYclausesorwiththeDISTINCToperatorinSELECTstatementsTheUNIQUEoperatorofaSELECTThecolumnlistofaCREATECLUSTEREMP_IMAGELONGgroupbyorderbyTheuseofLONGvaluesissubjecttotheseAtablecancontainonlyoneLONGYoucannotcreateanobjecttypewithaLONGLONGcolumnscannotappearinWHEREclausesorinintegrityconstraints(exceptthattheycanappearinNULLandNOTNULLconstraints).LONGYouneedtocreateatableforabankingapplication.OneofthecolumnsinthetablehasthefollowingYouwantacolumninthetabletostorethedurationofthecreditThedatainthecolumnshouldbestoredinaformatsuchthatitcanbeeasilyaddedDATEdatatypewithoutusingconversionTheumperiodofthecreditprovisionintheapplicationis30Theinteresthastobecalculatedforthenumberofdaysanindividualhastakenacreditfor.WhichdatatypewouldyouuseforsuchacolumnintheINTERVALDAYINTERVALYEARAnswer:datedateINTERVALDAYINTERVALDAYTOSECONDstoresaperiodoftimeintermsofdays,hours,minutes,andseconds.ThisdatatypeisusefulforrepresentingtheprecisedifferencebetweentwodatetimevaluesExaminethestructureproposedfortheTRANSACTIONStable:nameNullTypeTRANS_IDNOTNULLNUMBER(6)CUST_NAMENOTNULLVARCHAR2(20)CUST_STATUSNOTNULLCHARTRANS_DATENOTNULLDATETRANS_VALIDITYVARCHAR2CUST_CREDIT_LIMITNUMBERWhichstatementsaretrueregardingthecreationandstorageofdataintheabovetable(ChooseallthatTheCUST_STATUScolumnwouldgiveanTheTRANS_VALIDITYcolumnwouldgiveanTheCUST_STATUScolumnwouldstoreexactlyoneTheCUST_CREDIT_LIMITcolumnwouldnotbeabletostoredecimalTheTRANS_VALIDITYcolumnwouldhaveaumsizeofoneTheTRANS_DATEcolumnwouldbeabletostoreday,month,century,year,hour,minutes,seconds,andfractionsAnswer:ThedefaultlengthforaCHARcolumnis1byteandtheumallowedis2000bytes.A1-bytestringcanbeinsertedintoaCHAR(10)column,butthestringisblank-paddedto10bytesbeforeitisstored.C正确,AYoumustspecifyaumlengthforaVARCHAR2column.Thisummustbeatleast1byte,althoughtheactualstringstoredispermittedtobeazero-lengthstringB正确,EActualDataSpecifiedAsStored123.89NUMBERscott@ORCL>createtablezbcxy(idscott@ORCL>insertintozbcxy1scott@ORCL>select*fromDTheDATEdatatypestoresdateandtimeinformation.Althoughdateandtimeinformationcanberepresentedinbothcharacterandnumberdatatypes,theDATEdatatypehasspecialassociatedproperties.ForeachDATEvalue,Oraclestoresthefollowinginformation:year,month,day,hour,minute,andsecond.FExaminethestructureproposedfortheTRANSACTIONStable:nameNullTypeTRANS_IDNOTNULLNUMBER(6)CUST_NAMENOTNULLVARCHAR2(20)CUST_STATUSNOTNULLVARCHAR2TRANS_DATENOTNULLDATETRANS_VALIDITYINTERVALDAYTOSECONDWhichtwostatementsaretrueregardingthestorageofdataintheabovetablestructure?(Choosetwo.)TheTRANS_DATEcolumnwouldallowstorageofdatesonlyinthedd-mon-yyyyTheCUST_CREDIT_VALUEcolumnwouldallowstorageofpositiveandnegativeTheTRANS_VALIDITYcolumnwouldallowstorageofatimeintervalindays,hours,minutes,andTheCUST_STATUScolumnwouldallowstorageofdatauptotheumVARCHAR2sizeof4,000Answer:Ato_char设置多种格式TheNUMBERdatatypestoreszeroaswellaspositiveandnegativefixednumberswithabsolutevaluesfrom1.0x10-130tobutnotincluding1.0x10126.BINTERVALDAYTOSECONDstoresaperiodoftimeintermsofdays,hours,minutes,andseconds.Thisdatatypeisusefulforrepresentingtheprecisedifferencebetweentwodatetimevalues.CDvarcharDYouneedtocreateatablewiththefollowingcolumnEmployeeID(numericdatatype)foreachEmployeeName(characterdatatype)thatstorestheemployeeHiredate,whichstoresthedateofjoiningtheorganizationforeachStatus(characterdatatype),thatcontainsthevalue'ACTIVE'ifnodataisResume(characterlargeobject[CLOB]datatype),whichcontainstheresumesubmittedbytheWhichisthecorrectsyntaxtocreatethisCREATETABLE(emp_idNUMBER(4),emp_nameVARCHAR2(25),start_dateDATE,resumeCREATETABLE(emp_idNUMBER(4),emp_nameVARCHAR2(25),start_dateDATE,resumeCREATETABLE(emp_idNUMBER(4),emp_nameVARCHAR2(25),start_dateDATE,resumeCREATETABLE(emp_idNUMBER,emp_nameVARCHAR2(25),start_dateDATE,resumeAnswer:TheCLOBdatatypestoressingle-byteandmultibytecharacterdata.Bothfixed-widthandvariable-widthcharactersetsaresupportedandbothusethedatabasecharactersetclobA错BCdefault用单引号D正确WhichisthevalidCREATETABLECREATETABLEemp9$#(emp_noNUMBERCREATETABLE9emp$#(emp_noCREATETABLEemp*123(emp_noCREATETABLEemp9$#(emp_noNUMBER(4),dateAnswer:1-30字节,并且以字母开头,可以包含字oracle数据库的保留字BCDoracle中关键字作为属性名称A正确Whichtwostatementsaretrueregardingtables?(ChooseAtablenamecanbeofanyAtablecanhaveanynumberofAcolumnthathasaDEFAULTvaluecannotstorenullAtableandaviewcanhavethesamenameinthesameAtableandasynonymcanhavethesamenameinthesameThesametablenamecanbeusedindifferentschemasinthesameAnswer:1-30ABFORIIN1..999EXECUTEIMMEDIATE'ALTERTABLEzbcxyADDid'||I||'NUMBER(1)';ENDLOOP;scott@ORCL>altertablezbcxyaddid1000number(1);altertablezbcxyaddid1000number(1)*1行出现错误ORA-01792:oracle1000BCscott@ORCL>createtablezbcxy(namevarchar(20)defaultscott@ORCL>insertintozbcxyvalues('1scott@ORCL>select*fromCDDEscott@ORCL>createpublicsynonymempforscott@ORCL>createsynonymdeptfordept;createsynonymdeptfordept*1行出现错误ORA-01471:无法创建与对象同名的同义词EFWhichtwostatementsaretrueregardingconstraints?(ChooseAforeignkeycannotcontainNULLAcolumnwiththeUNIQUEconstraintcancontainNULLAconstraintisendonlyfortheINSERToperationonaAconstraintcanbedisabledeveniftheconstraintcolumncontainsAllconstraintscanbedefinedatthecolumnlevelaswellasthetableAnswer:Insertintozbcxyvaluesselecetenamefromemp;empename的控制插入zbcxy表中ABuniqueCinsertupdateDscott@ORCL>createtablezbcxy(idnumber(4)constraintp_pkprimaryscott@ORCL>insertintozbcxy1scott@ORCL>altertablezbcxydisableconstraintDEEWhichtwostatementsaretrueregardingconstraints?(ChooseAforeignkeycannotcontainNULLThecolumnwithaUNIQUEconstraintcanstoreNULLSAconstraintisendonlyforanINSERToperationonaYoucanhavemorethanonecolumninatableaspartofaprimaryAnswer:ABCD选项,一个表中只能有虽然只有一个约束,但是可以建立一个联合主键约束,这样就有D选项正确EvaluatethefollowingCREATETABLECREATETABLE(ord_noNUMBER(2)CONSTRAINTord_pkPRIMARYord_dateDATE,cust_idNUMBER(4));CREATETABLEord_items(ord_noNUMBER(2),item_noNUMBER(3),qtyNUMBER(3)CHECK(qtyBETWEEN100ANDexpiry_datedateCHECK(expiry_date>SYSDATE),CONSTRAINTit_pkPRIMARYKEY(ord_no,item_no),CONSTRAINTord_fkFOREIGNKEY(ord_no)REFERENCESorders(ord_no));Theabovecommandfailswhenexecuted.Whatcouldbethereason?SYSDATEcannotbeusedwiththeCHECKTheBETWEENclausecannotbeusedfortheCHECKTheCHECKconstraintcannotbecedoncolumnshavingtheDATEdataORD_NOandITEM_NOcannotbeusedasacompositeprimarykeybecauseORD_NOisalsotheFOREIGNAnswer:(ord_noitem_noqtyNUMBER(3)CHECK(qtyBETWEEN100ANDexpiry_datedateCHECK(expiry_date>CONSTRAINTit_pkPRIMARYKEYCONSTRAINTord_fkFOREIGNKEY(ord_no)REFERENCESorders(ord_no));expiry_datedateCHECK(expiry_date>SYSDATE),*5行出现错误ORA-02436:CHECKAEvaluatethefollowingSQLSQL>CREATESEQUENCEord_seqINCREMENTBY10STARTWITHMAXVALUE9999SQL>CREATE(ord_noNUMBER(4)DEFAULTord_seq.NEXTVALNOTqtyNUMBER(3)CHECK(qtyBETWEEN100ANDexpiry_datedateCHECK(expiry_date>SYSDATE),CONSTRAINTit_pkPRIMARYKEY(ord_no,item_no),CONSTRAINTord_fkFOREIGNKEY(ord_no)REFERENCESThecommandtocreateatablefails.IdentifythereasonfortheSQLstatementfailure?(ChooseallthatYoucannotuseSYSDATEintheconditionofaCHECKYoucannotusetheBETWEENclauseintheconditionofaCHECKYoucannotusetheNEXTVALsequencevalueasaDEFAULTvalueforaYoucannotuseORD_NOandITEM_NOcolumnsasacompositeprimarykeybecauseORD_NOisalsotheFOREIGNAnswer:(ord_noNUMBER(4)DEFAULTord_seq.NEXTVALNOTitem_noqtyNUMBER(3)CHECK(qtyBETWEEN100ANDexpiry_datedateCHECK(expiry_date>CONSTRAINTit_pkPRIMARYKEYCONSTRAINTord_fkFOREIGNKEY(ord_no)REFERENCESorders(ord_no));(ord_noNUMBER(4)DEFAULTord_seq.NEXTVALNOTNULL,*2行出现错误ORA-00984:A选项正确,B,D选项错误,经上面测试,CWhichCREATETABLEstatementisCREATETABLEord_details(ord_noNUMBER(2)PRIMARYKEY,ord_dateDATENOTCREATE(ord_noNUMBER(2)UNIQUE,NOTord_dateDATEDEFAULTSYSDATENOTCREATETABLEord_details(ord_noNUMBER(2),ord_dateDATEDEFAULTNOTCONSTRAINTord_uqUNIQUE(ord_no),CONSTRAINTord_pkPRIMARYKEY(ord_no));CREATETABLEord_details(ord_noNUMBER(2),ord_dateDATEDEFAULTSYSDATENOTCONSTRAINTord_pkPRIMARYKEY(ord_no,Answer:ABC选项:defaultscott@ORCL>createtablezbcxy(idconstraintp_iduconstraintp_idkprimaryconstraintp_idu*2行出现错误ORA-02261:DYouwanttocreateanORD_DETAILtabletostoredetailsforanordercedhavingthefollowingbusinessTheorderIDwillbeuniqueandcannothavenullTheorderdatecannothavenullvaluesandthedefaultshouldbethecurrentTheorderamountshouldnotbelessthanTheorderstatuswillhavevalueseithershippedornotTheorderpaymentmodeshouldbecheque,creditcard,orcashondeliveryWhichisthevalidDDLstatementforcreatingtheORD_DETAILCREATE(ord_idNUMBER(2)CONSTRAINTord_id_nnNOTNULL,ord_dateDATEDEFAULTSYSDATENOTNULL,ord_amountNUMBER(5,2)CONSTRAINTord_amount_minCHECK(ord_amount>50),ord_statusVARCHAR2(15)CONSTRAINTord_status_chkCHECK(ord_statusIN('Shipped','NotShipped')),ord_pay_modeVARCHAR2(15)CONSTRAINTord_pay_chkCHECK(ord_pay_modeIN('Cheque','CreditCard','CashOnCREATE(ord_idNUMBER(2)CONSTRAINTord_id_ukUNIQUENOTNULL,ord_dateDATEDEFAULTSYSDATENOTNULL,ord_amountNUMBER(5,2)CONSTRAINTord_amount_minCHECK(ord_amount>50),ord_statusVARCHAR2(15)CONSTRAINTord_status_chkCHECK(ord_statusIN('Shipped','NotShipped')),ord_pay_modeVARCHAR2(15)CONSTRAINTord_pay_chkCHECK(ord_pay_modeIN('Cheque','CreditCard','CashOnCREATE(ord_idNUMBER(2)CONSTRAINTord_id_pkPRIMARYKEY,ord_dateDATEDEFAULTSYSDATENOTNULL,ord_amountNUMBER(5,2)CONSTRAINTord_amount_minCHECK(ord_amount>=50),ord_statusVARCHAR2(15)CONSTRAINTord_status_chkCHECK(ord_statusIN('Shipped','NotShipped')),ord_pay_modeVARCHAR2(15)CONSTRAINTord_pay_chkCHECK(ord_pay_modeIN('Cheque','CreditCard','CashOnCREATETABLEord_details(ord_idNUMBER(2),ord_dateDATENOTNULLDEFAULTord_amountNUMBER(5,2)CONSTRAINTord_amount_minCHECK(ord_amount>=50),ord_statusVARCHAR2(15)CONSTRAINTord_status_chkCHECK(ord_statusIN('Shipped','NotShipped')),ord_pay_modeVARCHAR2(15)CONSTRAINTord_pay_chkCHECK(ord_pay_modeIN('Cheque','CreditCard','CashOnAnswer:根据题目第一句话:TheorderIDwillbeuniqueandcannothavenull只有主键才能满足这个条件,unique是可以为空值的C选项YoucreatedanORDERStablewiththefollowingdescription:nameNullTypeORD_IDNOTNULLNUMBER(2)CUST_IDNOTNULLNUMBER(3)ORD_DATENOTNULLDATEORD_AMOUNTNOTNULLNUMBERYouinsertedsomerowsinthetable.Aftersometime,youwanttoalterthetablebycreatingthePRIMARYKEYconstraintontheORD_IDcolumn.WhichstatementistrueinthisYoucannothavetwoconstraintsononeYoucannotaddaprimarykeyconstraintifdataexistsintheTheprimarykeyconstraintcanbecreatedonlyatthetimeoftablecreationYoucanaddtheprimarykeyconstraintevenifdataexists,providedthatthereareAnswerDscott@ORCL>select*from123scott@ORCL>altertablezbcxyaddconstraintp_pkprimaryscott@ORCL>select*from1232scott@ORCL>altertablezbcxyaddconstraintp_pkprimarykey(id);altertablezbcxyaddconstraintp_pkprimarykey(id)*1行出现错误ORA-02437:无法验证(SCOTT.P_PK)-主DWhichtwostatementsaretrueregardingconstraints?(ChooseAtablecanhaveonlyoneprimarykeyandoneforeignAtablecanhaveonlyoneprimarykeybutmultipleforeignOnlytheprimarykeycanbedefinedatthecolumnandtableTheforeignkeyandparenttableprimarykeymusthavethesameBothprimarykeyandforeignkeyconstraintscanbedefinedatbothcolumnandtableAnswer:ExaminethefollowingSQLSQL>CREATETABLEproductsprod_idNUMBER(3)CONSTRAINTp_ckCHECK(prod_id>0),prod_nameCHAR(30),prod_qtyNUMBER(6),CONSTRAINTp_nameNOTNULL,CONSTRAINTprod_pkPRIMARYKEY(prod_id));SQL>CREATETABLEwarehouse(warehouse_idroomnoNUMBER(10)CONSTRAINTr_idCHECK(roomnoBETWEEN101ANDlocationVARCHAR2(25),prod_idNUMBER(3),CONSTRAINTwr_pr_pkPRIMARYKEYCONSTRAINTprod_fkFOREIGNKEY(prod_id)REFERENCESproducts(prod_id));WhichstatementistrueregardingtheexecutionoftheaboveSQLcommands?BothcommandsThefirstCREATETABLEcommandgeneratesanerrorbecausetheNULLconstraintisnotvalid.ThesecondCREATETABLEcommandgeneratesanerro
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025浙江温州市洞头区机关事业单位(国企)第一期招聘编外用工12人笔试参考题库附带答案详解
- 2025浙江宁波奉化溪巷里商业运营管理有限公司招聘及笔试参考题库附带答案详解
- 国泰海通资产管理2027届校园招聘笔试历年难易错考点试卷带答案解析
- 青阳县2025年安徽池州青阳县事业单位招聘67人笔试历年参考题库典型考点附带答案详解
- 贵港市2025广西贵港市桂平市“浔找英才”急需紧缺人才专项招聘48人笔试历年参考题库典型考点附带答案详解
- 济南市2025年山东济南市市中区所属单位引进急需紧缺专业人才(8人)笔试历年参考题库典型考点附带答案详解
- 来宾市2025广西来宾市象州县政务服务和大数据发展局招聘编外工作人员1人笔试历年参考题库典型考点附带答案详解
- 2026年济南婚纱摄影服务能力横向深度测评:5家主流品牌全维度对比
- DB3707-T 033-2021 智慧供热系统建设技术规范
- 2026糖尿病膳食纤维粉食用课件
- 2025年《地质与矿业工程基础》真题(附答案)
- 2021公路项目安全性评价规程
- 康复护士进修结业汇报
- 2025年11月广东深圳市公办中小学招聘教师454人(编制)(公共基础知识)测试题附答案解析
- 胃食管反流常见症状及护理方法培训
- 消防交通安全培训课件下载
- 采伐安全施工技术交底
- 2025至2030全球及中国电脑游戏耳机行业项目调研及市场前景预测评估报告
- 2025长沙市望城区中小学教师招聘考试试题及答案
- 2025年高考湖北卷物理真题(原卷版)
- 2025年感术行动之围手术期感染防控试题附答案
评论
0/150
提交评论