`

Oracle常用函数

阅读更多
*在一个字符串中搜索指定的字符,返回发现指定的字符的位置
函数 INSTR(C1,C2,I,J)
C1    被搜索的字符串
C2    希望搜索的字符串I     搜索的开始位置,默认为1
J     出现的位置,默认为1
select instr('oracle traning','ra',1,2) instring from dual;



*返回字符串的长度
 函数 LENGTH
 select HIREDATE,length(to_char(HIREDATE)) from emp;




*将字符串转化为小写
 函数  LOWER
 select lower(ename) from emp;



*REPLACE('string','s1','s2')
string   希望被替换的字符或变量 
s1       被替换的字符串
s2       要替换的字符串
 select replace('he love you','he','i') from dual;



*将字符串转化为大写
 函数 upper
 select upper(ename) from emp;



*RPAD和LPAD(粘贴字符)
RPAD  在列的右边粘贴字符
LPAD  在列的左边粘贴字符
select lpad(rpad('gao',10,'*'),17,'*')from dual;


*LTRIM和RTRIM
LTRIM  删除左边出现的字符串
RTRIM  删除右边出现的字符串
select ltrim(rtrim('   gao qian jing   ',' '),' ') from dual;



*SUBSTR(string,start,count)
取子字符串,从start开始,取count个
 select substr('13088888888',3,8) from dual;










分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics