更新时间:2026-07-08 GMT+08:00
分享

translate

将 input 字符串中出现的 from 中的字符逐个替换为 to 中对应位置的字符。

例如:将 abcde 中的 bcd 替换成 BCD:

translate("abcde", "bcd", "BCD") 

命令格式

translate(string <input>, string <from>, string <to>) 

参数说明

参数

是否必选

参数类型

说明

input

STRING

待替换的字符串。

from

STRING

待替换的字符集合。

to

STRING

替换后的字符集合。

返回值说明

返回 STRING 类型。

如果任一输入参数值为 NULL,返回 NULL。

示例代码

返回 A1B2C3。

SELECT translate('AaBbCc', 'abc', '123');

相关文档