Oracle/PLSQL: TRANSLATE Function
The Oracle/PLSQL TRANSLATE function replaces a sequence of characters in a string with another set of characters. However, it replaces a single character at a time. For example, it will replace the 1st character in the string_to_replace with the 1st character in the replacement_string. Then it will replace the 2nd character in the string_to_replace with the 2nd character in the replacement_string, and so on.
TRANSLATE Function Syntax
The syntax for the TRANSLATE function is:
TRANSLATE( string1, string_to_replace, replacement_string )
string1 is the string to replace a sequence of characters with another set of characters.
string_to_replace is the string that will be searched for in string1.
replacement_string - All characters in the string_to_replace will be replaced with the corresponding character in the replacement_string.
The TRANSLATE function can be used in the following versions of Oracle/PLSQL:
- Oracle 12c, Oracle 11g, Oracle 10g, Oracle 9i, Oracle 8i
TRANSLATE Function Examples
The TRANSLATE function can be used in Oracle/PLSQL. For example:
|TRANSLATE('1tech23', '123', '456');||would return '4tech56'|
|TRANSLATE('222tech', '2ec', '3it');||would return '333tith'|