字符串函数

lower(expr):将表达式的结果转成小写
upper(expr):将表达式的结果转成大写.
length(str):获得字符串中字符的个数
lpad(expr1,n,expr2):将expr2的结果填充在expr1的左边得到长度为n的字符串
rpad(expr1,n,expr2):将expr2的结果填充在expr1的右边得到长度为n的字符串
substr(str,begin,length):从begin开始截取length个数据,begin从1,开始,如果为负数,从右向左执行.
concat(str1,str2):将两个字符串进行拼接,oralce中提供了||作为拼接符
trim(math FORM source) 从source中去掉前后的math
--查询员工姓名
select lower(ename) low,upper(ename) up,length(ename) len,
lpad(sal,10,'#') sal(http://www.amjmh.com/v/)
from emp;

--- 获得结果为 scott salary is 3000,but he want 5000
select concat(ename,concat(' salary is ', sal)) info from emp;
select ename ||' salary is '|| sal info from emp;

select trim(' abcd efg ') from dual;--去掉前后的空白
select trim('a' from 'aaa0123a456aa') from dual;
1
2
3
4
5
6
7
8
9
10
11

---------------------

原文地址:https://www.cnblogs.com/ly570/p/11335149.html