Oracle Plsql Translate Function

Oracle / PLSQL: TRANSLATE Function

This Oracle tutorial explains how to use the Oracle/PLSQL TRANSLATE function with syntax and examples.

Description

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.

Syntax

The syntax for the TRANSLATE function in Oracle/PLSQL is:

TRANSLATE( string1, string_to_replace, replacement_string )

Parameters or Arguments

string1

The string to replace a sequence of characters with another set of characters.

string_to_replace

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.

Returns

The TRANSLATE function returns a string value.

Applies To

The TRANSLATE function can be used in the following versions of Oracle/PLSQL:

  • Oracle 12c, Oracle 11g, Oracle 10g, Oracle 9i, Oracle 8i

Example

Let's look at some Oracle TRANSLATE function examples and explore how to use the TRANSLATE function in Oracle/PLSQL.

For example:

TRANSLATE('1aodb23', '123', '456')
Output: '4aodb56'

TRANSLATE('222aodb', '2ec', '3it')
Output: '333tith'