(1)lower : 小写, upper :大写,initcap :单词的首字母大写
select lower('HELLO WORLD') "小写", upper('Hello world') "大写", initcap('hello world') "首字母大写" from dual;
(2) concat ( 连接符|| )
select concat('hello ','world') from dual;
注意:concat 函数只能连接两个字符串,若想连接三个的话只能嵌套调用
select concat(concat('hello ','world'), ' nihao') from dual;
select 'hello ' || 'world ' || 'nihao' from dual;// || 可以连接多个字符串, 建议使用||来连接字符串
(3)substr(str, pos, len) 截取字符串
select substr('helloworld',1,3), substr('helloworld',1), substr('helloworld',-3) from dual;//pos 是从 1 开始的,若 len 为 0 表示从 pos 开始, 截取到最后,若 pos 为负数,表示从末尾倒数开始截取
(4) instr(str, substr):判断 substr 是否在 str 中存在,
select instr('hello llo', 'llo'), instr('hello llo', 'ow')from dual;//若存在返回第一次出现的位置,若不存在则返回 0
(5)lpad 和 rpad
返回 len 长度的字符串,如果 str 不够 len 的话,在左(右)填充 ch 这个字符
select lpad('aaaa', 10, '$'), rpad('aaaa', 10, '#') from dual;
(5)trim:去掉首部和尾部的空格;中间的空格不去掉
select 'aaa'||trim(' hello world ')||'bbb' from dual;
(6)trim(c from str):去掉 str 中的 c 字符
select trim('x' from 'xxxxxhello worldxxxxx') from dual;
(7) replace(str, old, new):将 str 字符串中的 old 字符串替换成 new 字符串
select replace('hello world','llo','yy') from dual;
(8)length 和 lengthb
select length('hello world') 字符数, lengthb('hello world') 字节数 from dual;