Definition:
The Oracle TRANSLATE function replaces one set of characters in a string with another set of characters. It performs the replacements in sequence, one character at a time, matching the character to be replaced with the replacement character.
TRANSLATE also allows for multiple targets for the replacement action to be performed on. This means that it will replace the 1st character in the target_string with the 1st character in the replacement_string. Then it will replace the 2nd character in the target_string with the 2nd character in the replacement_string, continuing until all the replacements have been made.
This example removes dashes in a phone number, replacing them with dots:
SELECT TRANSLATE('(425)555-1212', ')-(', '..') phone_number FROM DUAL;
Result:
425-555-1212
Related Links:
Related Code Snippets:
- TRANSLATE - Converts a character string into the character set specified for conversions between t...