在oracle中,trim()函数的用法有,leading 开头字符,trailing 结尾字符,both 开头和结尾字符,如下:
trim(leading || trailing || both '将要被替换掉的字符" from “将要被替换的字符串")
1、trim函数去除指定的开头字符
select trim(leading 'x' from 'xday') as strTemp from tableName ;
2、trim函数去除指定的结尾字符
select trim(trailing 'x' from 'dayx') as strTemp from tableName ;
3、trim函数去除指定的首部和尾部字符
select trim(both 'x' from 'xdayx') as strTemp from tableName ;
4、默认情况下,trim函数会去除首部和尾部,被指定的字符
select trim('x' from 'xdayx') as strTemp from tableName ;
5、如果没有指定被移除的字符,则会默认去除首部和尾部的空格
select trim(' day ') as strTemp from tableName ;