chr(n):把指定的Ascii码转换为字符。
select chr(97) from dual; 输出a。
ascii(char):返回指定char的ascii码。
select ascii('a') from dual; 输出97。
length(string):返回指定字符串的长度。
select length('helloworld') from dual; 输出10。
upper(char):将字符串转换为大写字母。
select upper('helloworld') from dual;输出HELLOWORLD。
lower(char):将字符串转换为小写。
select lower('HELLOWORLD') from dual;输出helloworld。
initcap(char):将所有单词的首字母转换为大写。
select initcap('hello world') from dual;输出Hello World。
instr(string,substring,position,occurrence):搜索string中是否存在substring。position表示搜索的开始位置,默认为1,如果为负数,则表示从字符串右边开始搜索。occurrence表示substring第几次出现。
select instrI('helloworld','lo') from dual;输出4。
select instr('helloworld','l',5) from dual;输出9.
select instr('helloworld','l',1,3) from dual;输出9.
select instr('helloworld','l',4,3) from dual;输出0。因为从第四个字符开始搜索,此时只能搜索到两个'l',不存在第三个'l',故会返回0.
substr(string,position,sub_length):从string的第position位开始,截取sub_length长度。默认position为1,如果position为负数,则从stirng右边开始截取。
select substr('helloworld',4,2) from dual;输出lo。
select substr('helloworld',4,2) from dual;输出or。
trim([leading/trailing/both][trim_character FROM]trim_source):删除指定的前缀或尾随字符。默认删除空格。
leading表示删除前缀字符。trailing表示删除后缀字符。both表示删除前缀和后缀字符。截取集只能有一个字符
select trim(leading 'h' from 'helloworld') from dual;输出elloworld.
select trim(trailing 'd' from 'helloworld') from dual;输出helloworl.
select trim(both 'h' from 'helloworldh') from dual;输出elloworld。这里不能使用(both 'h','d')或(both 'hd')的写法。
rtrim(char,[set]):将char右边出现在set的字符删掉。当遇到非set中的字符时就停止。
select rtrim('helloworld','dl') from dual;输出hellowor。
select rtirm('helloworld','dr') from dual;输出helloworl(遇到‘l’时,就停止了删除)。
ltrim(char,[set]):与rtrim相似,ltrim删掉char左边出现在set的字符。
replace(char,string,replace_stirng):将char中的string替换为replace_tring。
select replace('helloworld','hello','hi') from dual;输出hiworld。
rpad(string,n,[char]):用char在string的右边将string的长度增加到n。如果string的长度大于n,则变为截取string到n的长度。
select rpad('helloworld',11,'1') from dual; 输出helloworld1。
select rpad('helloworld',13,'1234') from dual;输出helloworld123。helloworld原长度为10,用‘1234’中的每个字符去填充helloworld,当string长度为13时,string变为helloworld123.此时停止填充。
select rpad('helloworld',8,'1') from dual;输出hellowor。