oracle110个常用函数

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

1.ASCII返回与指定的字符对应的十进制数;SQLselectascii(A)A,ascii(a)a,ascii(0)zero,ascii()spacefromdual;AAZEROSPACE------------------------------------659748322.CHR给出整数,返回对应的字符;SQLselectchr(54740)zhao,chr(65)chr65fromdual;ZHC---赵A3.CONCAT连接两个字符串;SQLselectconcat(010-,88888888)||转23高乾竞电话fromdual;高乾竞电话----------------010-88888888转234.INITCAP返回字符串并将字符串的第一个字母变为大写;SQLselectinitcap(smith)uppfromdual;UPP-----Smith5.INSTR(C1,C2,I,J)在一个字符串中搜索指定的字符,返回发现指定的字符的位置;C1被搜索的字符串C2希望搜索的字符串I搜索的开始位置,默认为1J出现的位置,默认为1SQLselectinstr(oracletraning,ra,1,2)instringfromdual;INSTRING---------96.LENGTH返回字符串的长度;SQLselectname,length(name),addr,length(addr),sal,length(to_char(sal))fromgao.nchar_tst;NAMELENGTH(NAME)ADDRLENGTH(ADDR)SALLENGTH(TO_CHAR(SAL))---------------------------------------------------------------------------高乾竞3北京市海锭区69999.9977.LOWER返回字符串,并将所有的字符小写SQLselectlower(AaBbCcDd)AaBbCcDdfromdual;AABBCCDD--------aabbccdd8.UPPER返回字符串,并将所有的字符大写SQLselectupper(AaBbCcDd)upperfromdual;UPPER--------AABBCCDD9.RPAD和LPAD(粘贴字符)RPAD在列的右边粘贴字符LPAD在列的左边粘贴字符SQLselectlpad(rpad(gao,10,*),17,*)fromdual;LPAD(RPAD(GAO,1-----------------*******gao*******不够字符则用*来填满10.LTRIM和RTRIMLTRIM删除左边出现的字符串RTRIM删除右边出现的字符串SQLselectltrim(rtrim(gaoqianjing,),)fromdual;LTRIM(RTRIM(-------------gaoqianjing11.SUBSTR(string,start,count)取子字符串,从start开始,取count个SQLselectsubstr(13088888888,3,8)fromdual;SUBSTR(--------0888888812.REPLACE(string,s1,s2)string希望被替换的字符或变量s1被替换的字符串s2要替换的字符串SQLselectreplace(heloveyou,he,i)fromdual;REPLACE(H----------iloveyou13.SOUNDEX返回一个与给定的字符串读音相同的字符串SQLcreatetabletable1(xmvarchar(8));SQLinsertintotable1values(weather);SQLinsertintotable1values(wether);SQLinsertintotable1values(gao);SQLselectxmfromtable1wheresoundex(xm)=soundex(weather);XM--------weatherwether•14.TRIM(sfromstring)LEADING剪掉前面的字符TRAILING剪掉后面的字符如果不指定,默认为空格符15.ABS返回指定值的绝对值SQLselectabs(100),abs(-100)fromdual;ABS(100)ABS(-100)------------------10010016.ACOS给出反余弦的值SQLselectacos(-1)fromdual;ACOS(-1)---------3.141592717.ASIN给出反正弦的值SQLselectasin(0.5)fromdual;ASIN(0.5)---------.5235987818.ATAN返回一个数字的反正切值SQLselectatan(1)fromdual;ATAN(1)---------.7853981619.CEIL返回大于或等于给出数字的最小整数SQLselectceil(3.1415927)fromdual;CEIL(3.1415927)---------------420.COS返回一个给定数字的余弦SQLselectcos(-3.1415927)fromdual;COS(-3.1415927)----------------121.COSH返回一个数字反余弦值SQLselectcosh(20)fromdual;COSH(20)---------24258259822.EXP返回一个数字e的n次方根SQLselectexp(2),exp(1)fromdual;EXP(2)EXP(1)------------------7.38905612.718281823.FLOOR对给定的数字取整数SQLselectfloor(2345.67)fromdual;FLOOR(2345.67)--------------234524.LN返回一个数字的对数值SQLselectln(1),ln(2),ln(2.7182818)fromdual;LN(1)LN(2)LN(2.7182818)-------------------------------0.69314718.9999999925.LOG(n1,n2)返回一个以n1为底n2的对数SQLselectlog(2,1),log(2,4)fromdual;LOG(2,1)LOG(2,4)------------------0226.MOD(n1,n2)返回一个n1除以n2的余数SQLselectmod(10,3),mod(3,3),mod(2,3)fromdual;MOD(10,3)MOD(3,3)MOD(2,3)---------------------------10227.POWER返回n1的n2次方根SQLselectpower(2,10),power(3,3)fromdual;POWER(2,10)POWER(3,3)---------------------10242728.ROUND和TRUNC按照指定的精度进行舍入SQLselectround(55.5),round(-55.4),trunc(55.5),trunc(-55.5)fromdual;ROUND(55.5)ROUND(-55.4)TRUNC(55.5)TRUNC(-55.5)----------------------------------------------56-5555-5529.SIGN取数字n的符号,大于0返回1,小于0返回-1,等于0返回0SQLselectsign(123),sign(-100),sign(0)fromdual;SIGN(123)SIGN(-100)SIGN(0)----------------------------1-1030.SIN返回一个数字的正弦值SQLselectsin(1.57079)fromdual;SIN(1.57079)------------1•31.SIGH返回双曲正弦的值SQLselectsin(20),sinh(20)fromdual;SIN(20)SINH(20)------------------.9129452524258259832.SQRT返回数字n的根SQLselectsqrt(64),sqrt(10)fromdual;SQRT(64)SQRT(10)------------------83.162277733.TAN返回数字的正切值SQLselecttan(20),tan(10)fromdual;TAN(20)TAN(10)------------------2.2371609.6483608334.TANH返回数字n的双曲正切值SQLselecttanh(20),tan(20)fromdual;TANH(20)TAN(20)------------------12.237160935.TRUNC按照指定的精度截取一个数SQLselecttrunc(124.1666,-2)trunc1,trunc(124.16666,2)fromdual;TRUNC1TRUNC(124.16666,2)---------------------------100124.1636.ADD_MONTHS增加或减去月份SQLselectto_char(add_months(to_date(199912,yyyymm),2),yyyymm)fromdual;TO_CHA------200002SQLselectto_char(add_months(to_date(199912,yyyymm),-2),yyyymm)fromdual;TO_CHA------19991037.LAST_DAY返回日期的最后一天SQLselectto_char(sysdate,yyyy.mm.dd),to_char((sysdate)+1,yyyy.mm.dd)fromdual;TO_CHAR(SYTO_CHAR((S--------------------2004.05.092004.05.10SQLselectlast_day(sysdate)fromdual;LAST_DAY(S----------31-5月-0438.MONTHS_BETWEEN(date2,date1)给出date2-date1的月份SQLselectmonths_between(19-12月-1999,19-3月-1999)mon_betweenfromdual;MON_BETWEEN-----------9SQLselectmonths_between(to_date(2000.05.20,yyyy.mm.dd),to_date(2005.05.20,yyyy.mm.dd))mon_betwfromdual;MON_BETW----------6039.NEW_TIME(date,this,that)给出在this时区=other时区的日期和时间SQLselectto_char(sysdate,yyyy.mm.ddhh24:mi:ss)bj_time,to_char(new_time2(sysdate,PDT,GMT),yyyy.mm.ddhh24:mi:ss)los_anglesfromdual;BJ_TIMELOS_ANGLES--------------------------------------2004.05.0911:05:322004.05.0918:05:3240.NEXT_DAY(date,day)给出日期date和星期x之后计算下一个星期的日期SQLselectnext_day('18-5月-2001','星期五')next_dayfromdual;NEXT_DAY----------

1 / 42
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功