SQL TRIM()函数
TRIM([{BOTH | LEADING | TRAILING} [remstr] FROM] str)
TRIM([remstr FROM] str)
返回字符串str,删除了所有使用Remstar前缀或后缀。如果没有说明符BOTH,LEADING,或TRAILING给出,BOTH是假定(默认)的。Remstar是可选的,如果未指定,空格被删除。
SQL> SELECT TRIM(' bar '); +---------------------------------------------------------+ | TRIM(' bar ') | +---------------------------------------------------------+ | bar | +---------------------------------------------------------+ 1 row in set (0.00 sec) SQL> SELECT TRIM(LEADING 'x' FROM 'xxxbarxxx'); +---------------------------------------------------------+ | TRIM(LEADING 'x' FROM 'xxxbarxxx') | +---------------------------------------------------------+ | barxxx | +---------------------------------------------------------+ 1 row in set (0.00 sec) SQL> SELECT TRIM(BOTH 'x' FROM 'xxxbarxxx'); +---------------------------------------------------------+ | TRIM(BOTH 'x' FROM 'xxxbarxxx') | +---------------------------------------------------------+ | bar | +---------------------------------------------------------+ 1 row in set (0.00 sec) SQL> SELECT TRIM(TRAILING 'xyz' FROM 'barxxyz'); +---------------------------------------------------------+ | TRIM(TRAILING 'xyz' FROM 'barxxyz') | +---------------------------------------------------------+ | barx | +---------------------------------------------------------+ 1 row in set (0.00 sec)