1. replace,translate
--translate 字符級別的替換 --replace 字符串級別的替換 select replace('abaabbb','ab','c') from dual;--cacbb select translate('aaabbb','ab','ce') from dual;--ccceee
2. concat 字符串連接,等同於 ||
select concat('test', '_concat') from dual;--test_concat select 'test' || '_concat' from dual; --test_concat
3. upper,lower,initcap 指定語言集的方法:NLS_UPPER,NLS_LOWER,NLS_INITCAP
select upper('AaaaAa') from dual; --AAAAAA select lower('AaaaAa') from dual; --aaaaaa select initcap('aaaaa') from dual; --Aaaaa select initcap('aaa aaa') from dual; --Aaa Aaa
4.lpad,rpad 字符串填充,如果不指定填充字符,默認為空格
select lpad('aa',10,'0') from dual; --左填充 00000000aa select rpad('aa',10,'0') from dual; --右填充 aa00000000
5. ltrim,rtrim,trim(leading,trailing,both) 字符串修剪,trim只支持單字符修剪? 默認剪去空格
select ltrim('111111111000123000','01') from dual; --從左截掉所有0和1 23000 select rtrim('00012300011111','012') from dual;----從右截掉所有0和1 000123 select trim(leading '0' from '000123000') from dual; --從頭截掉所有的0 123000 select trim(trailing '0' from '000123000') from dual; --從尾截掉所有的0 000123 select trim(both '0' from '000123000') from dual; --兩邊同時截掉所有的0 123
6. substr
--substr(char,start,length) 截取char從start開始的長度為length的字符串 select substr('abc',0,1) from dual; --返回a select substr('abc',1,1) from dual;--start為0和start為1效果相同 select substr('abcdefgs',-5,3) from dual;--如果start為負數,則從倒數第start個字符開始截取 返回def select substr('abcdefgs',-5) from dual;--如果省略length,則截取start直到結尾的字符串 返回defgs
7. regexp_substr,regexp_replace