gloria@www.dweye.net> select trim ('x' from 'xxxxDWEYExxxx') "TRIM e.g." from dual; TRIM e.g -------DWEYE 配合“BOTH”“TRAILING”和“LEADING”三个参数使用效果如下,与之前演示类似。看结 、 果,不赘述。 gloria@www.dweye.net> select trim (both 'x' from 'xxxxDWEYExxxx') "TRIM e.g." from dual; TRIM e.g -------DWEYE gloria@www.dweye.net> select trim (trailing 'x' from 'xxxxDWEYExxxx') "TRIM e.g." from dual; TRIM e.g. -----------xxxxDWEYE gloria@www.dweye.net> select trim (leading 'x' from 'xxxxDWEYExxxx') "TRIM e.g." from dual; TRIM e.g. -----------DWEYExxxx 6.需要注意的地方 这里的“trim_character”参数只允许包含一个字符,不支持多字符。 报错信息如下: gloria@www.dweye.net> select trim (leading 'xy' from 'xyxxDWEYExyyx') "TRIM e.g." from dual; select trim (leading 'xy' from 'xyxxDWEYExyyx') "TRIM e.g." from dual * ERROR at line 1: ORA-30001: trim set should have only one character 既然 TRIM 不能满足我们删除只剩“DWEYE”字符串的要求,有么有其他手段呢?of course 有。我们使用 RTRIM 和 LTRIM“连环拳”完成这个任务。 1)使用 RTRIM gloria@www.dweye.net> select rtrim('xyxxDWEYExyyx','xy') "e.g." from dual; e.g. ------------
xyxxDWEYE 2)使用 LTRIM gloria@www.dweye.net> select ltrim('xyxxDWEYExyyx','xy') "e.g." from dual; e.g. -----------DWEYExyyx 3)联合使用 RTRIM 和 LTRIM 函数达到我们的目的 gloria@www.dweye.net> select ltrim(rtrim('xyxxDWEYExyyx','xy'),'xy') "e.g." from dual; e.g. -------DWEYE 使用 RTRIM 和 LTRIM 函数时的注意事项: “xy”不表示整个“xy”字符串进行匹配,而是发现 任意的字符“x”或字符“y”均做删除操作。
如 果 所 有 自 变 量 均 为 IS NOT NULL) THEN expression1 NULL ...
NULL , 则
COALESCE CASE
返 回
NULL
值 。
COALESCE(expression1,...n) 与此 CASE 函数等价:
WHEN (expression1
WHEN (expressionN IS NOT NULL) THEN expressionN
ELSE
格式为: NVL( string1, replace_with) 功能:如果 string1 为 NULL, NVL 函数返回 replace_with 则 的值,否则 否则返回 string1 的值,如果两个参数的都为 NULL ,则返回 NULL。
十:to_char
The following are number examples for the to_char function. to_char (1210.73, '9999.9') would return '1210.7' to_char (1210.73, '9,999.99') would return '1,210.73' to_char (1210.73, '$9,999.00') would return '$1,210.73' to_char (21, '000099') would return '000021' The following is a list of valid parameters when the to_cha