ocp051题库笔记讲解-1z0-v9.02解析_第1页
ocp051题库笔记讲解-1z0-v9.02解析_第2页
ocp051题库笔记讲解-1z0-v9.02解析_第3页
已阅读5页,还剩4页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1Z0-051V9.022017-5-25YouarecurrentlylocatedinSingaporeandhaveconnectedtoaremotedatabaseinChicago.YouissuethefollowingSQL>SELECTROUND(SYSDATE-promo_begin_date,0)FROMpromotionsWHERE(SYSDATE-promo_begin_date)/365>PROMOTIONSisthepublicsynonymforthepublicdatabaselinkforthePROMOTIONStable.Whatis anerrorbecausetheROUNDfunctionspecifiedisanerrorbecausetheWHEREconditionspecifiedisdateandtime.numberofdayssincethepromostartedbasedonthecurrentSingaporedateandtime.执行下执行下 令PROMOTIONSpublicsynonympublicdatabaselink执行下 数据库 SELECTSYSDATE-TO_DATE('2017-5-1','YYYY-MM-DD')FROMSELECTROUND(SYSDATE-TO_DATE('2017-5-1','YYYY-MM-DD'))FROMDUAL;017-5-1','YYYY-MM-DD'),5)FROMDUAL;selectselectsysdatefromdual;--ExaminethedataintheCUST_NAMEcolumnoftheCUSTOMERStable.RenskeLadwigJasonMallinSamuelMcCainAllanMCEwenIreneMikkilineniJuliaNayerYouneedtodisplaycustomers'secondnameswherethesecondnamestartswith"Mc"or"MC."WhichquerygivestherequiredSELECTSUBSTR(cust_name,INSTR(cust_name,'')+1)FROMcustomersWHEREINITCAP(SUBSTR(cust_name,INSTR(cust_name,'SELECTSUBSTR(cust_name,INSTR(cust_name,'')+1)FROMcustomersWHEREINITCAP(SUBSTR(cust_name,INSTR(cust_name,'')+1))LIKESELECTSUBSTR(cust_name,INSTR(cust_name,'')+1)FROMcustomers SELECTSUBSTR(cust_name,INSTR(cust_name,'')+1)FROMcustomersWHEREINITCAP(SUBSTR(cust_name,INSTR(cust_name,'')+1))=要显示第二个名字以"Mcor"MC"开头的员工第二个名B选项正确,INSTRSUBSTR从空格后开始找,把找出的结果首like模糊查询。MC。 createviewv_customersasselectcust_first_name||''||cust_last_nameascust_namefromcustomers;selectcount(*)fromv_customersSELECTcount(*)FROMv_customerstWHEREcust_nameLIKE'%Mc%'--SELECTSUBSTR(cust_name,INSTR(cust_name,'')+1)FROMv_customersSELECTSUBSTR(cust_name,INSTR(cust_name,'')+1)FROMv_customersWHEREINITCAP(SUBSTR(cust_name,INSTR(cust_name,'')+1))LIKESELECTSUBSTR(cust_name,INSTR(cust_name,'')+1)FROMv_customersWHERESUBSTR(cust_name,INSTR(cust_name,'')+1)LIKEorSUBSTR(cust_name,INSTR(cust_name,'')+1)LIKE;SELECTSUBSTR(cust_name,INSTR(cust_name,'')+1)FROMv_customersWHEREINITCAP(SUBSTR(cust_name,INSTR(cust_name,'')+1))likeSELECT*FROMV_CUSTOMERSWHEREINSTR(CUST_NAME,'SELECTLPAD(SUBSTR(cust_name,INSTR(cust_name,'')),LENGTH(cust_name),'*')"CUSTNAME"FROMWHEREWHEREINSTR(cust_name,'SELECTLPAD(SUBSTR(cust_name,INSTR(cust_name,'')),LENGTH(cust_name),'*')"CUSTNAME"FROMWHEREINSTR(cust_name,'',-ExaminethedataintheCUST_NAMEcolumnoftheCUSTOMERStable.LexDeHaanRenskeLadwigJoseManuelUrmanJasonMallinYouwanttoextractonlythosecustomernamesthathavethreenamesanddisplaythe*symbolinplaceofthefirstnameasfollows:CUSTNAME***De****ManuelWhichtwoqueriesgivetherequiredoutput?(Choose ')),LENGTH(cust_name),'*')"CUSTNAME"FROMWHEREINSTR(cust_name,' ')),LENGTH(cust_name),'*')"CUSTNAME"FROMWHEREINSTR(cust_name,'',- INSTR(cust_name,''),'*')"CUSTFROMWHEREINSTR(cust_name,'',-1,- ')),LENGTH(cust_name)-INSTR(cust_name,''),'*')"CUSTNAME"FROMWHEREINSTR(cust_name,'LexDeHaanRenskeLadwigJoseManuelUrmanJasonMallinCUST***De****ManuelINSTR(cust_name然后,SUBSTR(cust_name,INSTR(cust_name从第一个空格开始往后')),LENGTH(cust_name),'*')LPADcust_name原来的长度,不足的部AINSTR(cust_name',1,2)从第一个位置,从左往右,查找第二次出0值,则说明有第二个空格,则有第三个名字,BINSTR(cust_name1,2)从最后一个位置,从右往左,查找第二0值,则说明有第二个空格,则有第三个名字。C选项不正确,INSTR(cust_name1,-2)第四个参数,是第几次出现,这里不DLENGTH(cust_nameINSTR(cust_name,,是总长度,SELECTLPAD(SUBSTR(cust_name,INSTR(cust_name,'')),LENGTH(cust_name)-INSTR(cust_name,''),'*')"CUSTNAME"FROMWHEREINSTR(cust_name,'selectLPAD(SUBSTR('WEIHAIBIN',4),LENGTH('WEIHAIBIN'),'*')FROMSELECTSELECTLPAD(SUBSTR(cust_name,INSTR(cust_name,'')),LENGTH(cust_name),'*')"CUSTNAME"FROMWHEREINSTR(cust_name,'ExaminethedataintheENAMEandHIREDATEcolumnsoftheEMPLOYEES YouwanttogeneratealistofuserIDsasfollows:YouissuethefollowingSQL>SELECTCONCAT(SUBSTR(INITCAP(ename),1,3),REPLACE(hiredate,'-'))FROMWhatis ItexecutessuccessfullyandgivesthecorrectItexecutessuccessfullybutdoesnotgivethecorrectItgeneratesanerrorbecausetheREPLACEfunctionisnotItgeneratesanerrorbecausetheSUBSTRfunctioncannotbenestedintheCONCATfunction.ENAMEandHIREDATE SELECTCONCAT(SUBSTR(INITCAP(ename),1,3),REPLACE(hiredate,'-'))FROMSELECTLAST_NAME,hire_dateFROM SELECTCONCAT(SUBSTR(INITCAP(LAST_name),1,3),REPLACE(hire_date,'-'))"USERID"FROMSELECThire_dateFROMSELECTREPLACE(HIRE_DATE,'/')FROMSELECTREPLACE(HIRE_DATE,'-')FROMEMPLOYEES;--date隐式转换为字符串认显示格式是SELECTSELECTTO_CHAR(HIRE_DATE)FROMSELECTTO_CHAR(HIRE_DATE,'dd-MON-rr')FROMWhichstatementsaretrueregardingdatatypeconversioninexpressionsusedinqueries?(Chooseallthatapply.)inv_amt ':requiresexplicitinv_date>'01-02-2008':usesimplicitCONCAT(inv_amt,inv_date):requiresexplicitinv_date='15-february- :usesimplicitinv_noBETWEEN'101'AND'110':usesimplicitA.inv_amt inv_date01-02-2008')inv_date15-february-2008inv_noBETWEEN101AND110'表的结构fromfromdual;fromfromdual;--fromselectcasewhen'2'-1>0then'YES'ELSE'NO'ENDFROMDUAL;selectcasewhen'01-MAY-17'

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论