Oracle replace替换多个,oracle 的两个替换函数 REPLACE TRANSLATE

replace就是一般意义上的字符串替换,translate只是一个字符替换对应的一个字符,下面有手册说明,还有例子 O(∩_∩)O哈哈~

REPLACE

Syntax

Purpose

REPLACE returns char with every occurrence of search_string replaced with replacement_string. If replacement_string is omitted or null, then all occurrences of search_string are removed. If search_string is null, then char is returned.

Both search_string and replacement_string, as well as char, can be any of the datatypes CHAR, VARCHAR2, NCHAR, NVARCHAR2, CLOB, or NCLOB. The string returned is in the same character set as char. The function returns VARCHAR2 if the first argument is not a LOB and returns CLOB if the first argument is a LOB.

REPLACE provides functionality related to that provided by the TRANSLATE function. TRANSLATE provides single-character, one-to-one substitution. REPLACE lets you substitute one string for another as well as to remove character strings.

Examples

The following example replaces occurrences of J with BL:

SELECT REPLACE('JACK and JUE','J','BL') "Changes"

from DUAL;

Changes

--------------

BLACK and BLUE

TRANSLATE

Syntax

PurposeTRANSLATE returns expr with all occurrences of each character in from_string replaced by its corresponding character in to_string.

Characters in expr that are not in from_string are not replaced. If expr is a character string, then you must enclose it in single

quotation marks. The argument from_string can contain more characters than to_string. In this case, the extra characters at the

end of from_string have no corresponding characters in to_string. If these extra characters appear in char, then they are removed

from the return value.

You cannot use an empty string for to_string to remove all characters in from_string from the return value. Oracle Database

interprets the empty string as null, and if this function has a null argument, then it returns null.

TRANSLATE provides functionality related to that provided by the REPLACE function

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值