The TRANSLATE function in Oracle replaces a character or set of characters in a string. Syntax: TRANSLATE(string, from_list, to_list). Parameters: string (input string), from_list (character or character set to be replaced), to_list (replacement character or character set). Usage: Traverse the characters in from_list, find matches in string and replace them with the corresponding characters in to_list. Examples: Convert lowercase letters to uppercase letters, convert numbers to asterisks, replace specific characters with other characters.
TRANSLATE function in Oracle
The TRANSLATE function in Oracle is used to convert specific characters or Character set is replaced with another character or character set.
Syntax
<code>TRANSLATE(string, from_list, to_list)</code>
Parameters
Usage
The TRANSLATE function works in the following manner:
Example
<code>-- 将字符串中的所有小写字母转换为大写字母 SELECT TRANSLATE('hello world', 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ') FROM dual; -- 结果:HELLO WORLD -- 将字符串中的数字转换为星号 SELECT TRANSLATE('12345', '0123456789', '**********') FROM dual; -- 结果:****** -- 将字符串中的特定字符替换为其他字符 SELECT TRANSLATE('Hello, World!', '!,', '??') FROM dual; -- 结果:Hello?? World??</code>
Notes
The above is the detailed content of How to use translate in oracle. For more information, please follow other related articles on the PHP Chinese website!