oracle中常用单行函数字符串函数总结

字符串函数

 函数名称  函数描述  函数应用实例
 UPPER(列|字符串) 把列字符串转换为大写 ,返回字符串

例:select UPPER('helloworld') from dual;

例:select ename,enumber,sal from emp where ename=UPPER('smith')

例:select eno,ename from emp where ename=upper('&inputname')

LOWER(列|字符串) 把列字符串转换为小写,返回字符串

例:select LOWER('HELLO') from dual;

例:select LOWER(ename),enumber,sal from emp;

INITCAP(列|字符串) 把列,字符串的每个单词首字母大写其他的字母转小写 例:select INITCAP('helloworld') from dual;
LENGTH(列|字符串) 返回数字,列的长度 例: select length('helloworld') from dual
substr(列|字符串,开始索引,[长度])

截取字符串的一部分,从指定位置截取到结尾,从指定位置,

截取指定长度,注意,oracle中索引从1开始,如果写成0,

也是从1开始,截取长度也可以为负数,从右侧开始截取

例:select substr('helloworld',6) from dual;

例:select substr('helloworld',1,5) from dual;

截取emp表中,ename的最后三个字符

select ename ,substr(ename,length(ename)-2) from emp;

select ename,substr(ename,-3) from emp;

 

replace(列|字符串,旧内容,新内容) 把字符串,列的一部分替换 例:select  ename,replace(ename,'S','t') as  name from ename;
posted @ 2019-04-23 12:58  自动化前行者  阅读(235)  评论(0编辑  收藏  举报