版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2024-2030年全球及中国牛胶原蛋白行业销售动态及需求前景预测报告
- 2024-2030年全球及中国汽车钢材行业产销现状及需求规模预测报告
- 2024-2030年全球及中国无铅焊丝行业运营态势及投资盈利预测报告
- 2024-2030年全球及中国双丙酮醇行业供需现状及发展趋势预测报告
- 2024-2030年全球及中国产后康复设备行业需求前景及营销前景预测报告
- 2024-2030年全球与中国异戊酯行业产销情况及需求前景预测报告
- 2024年工程项目二次结构专业分包合同
- 2024-2030年中国饲料酸化剂行业发展趋势及项目可行性分析报告
- 2024-2030年中国食品脱水机行业销售渠道与投资盈利预测报告
- 2024-2030年中国风电机组控制系统行业发展现状规划分析报告
- 第16讲 国家出路的探索与挽救民族危亡的斗争 课件高三统编版(2019)必修中外历史纲要上一轮复习
- 机器学习 课件 第10、11章 人工神经网络、强化学习
- 北京市人民大学附属中学2025届高二生物第一学期期末学业水平测试试题含解析
- 书籍小兵张嘎课件
- 氢气中卤化物、甲酸的测定 离子色谱法-编制说明
- 2024秋期国家开放大学专科《机械制图》一平台在线形考(形成性任务四)试题及答案
- 2024年经济师考试-中级经济师考试近5年真题集锦(频考类试题)带答案
- 2024年黑龙江哈尔滨市通河县所属事业单位招聘74人(第二批)易考易错模拟试题(共500题)试卷后附参考答案
- 私募基金管理人-廉洁从业管理准则
- 房地产估价机构内部管理制度
- 艺术哲学:美是如何诞生的学习通超星期末考试答案章节答案2024年
评论
0/150
提交评论