查看原文:http://www.ibloger.net/article/255.html
常见的用法是去除空格,有多少人不知道它们其实还可以做到去除空格,它有ltrim()、ltrim(x,y)方法
------- 去两边空格,去左空格,去右空格 --------
select trim(' X-rapido ') name from dual; 返回 'X-rapido'
select ltrim(' X-rapido ') name from dual; 返回 'X-rapido '
select rtrim(' X-rapido ') name from dual; 返回 '' X-rapido''
select trim(null) name from dual; 返回null
ltrim(x,y)语法
结果:cdabababe
select ltrim('aaaaaa','a') word from dual;
结果:null空
select ltrim('109224323','109') nums from dual;
结果:224323
select ltrim('10900094323','109') nums from dual;
结果:4323
select ltrim('10900111000991110224323','109') nums from dual;
结果:224323
select ltrim('109200111000991110224323','109') nums from dual;
结果:200111000991110224323
select ltrim('902100111000991110224323','109') nums from dual;
结果:2100111000991110224323
注意:Oracle区分大小写
select ltrim('abcdab','B') word from dual;
结果:abcdab
至于rtrim函数,与ltrim同理,一个从左边开始,一个从右边开始
截取字符串的功能不同于substr函数,因为一个是指定字符,一个是指定下标