The TRANSLATE function in Oracle SQL is used to replace a set of characters in a string with another set of characters.
It takes three arguments:
- The input string
- The set of characters to be replaced
- The set of replacement characters
Here is an example of how to use the TRANSLATE function in Oracle SQL
SELECT TRANSLATE('HELLO WORLD', 'OD', 'XY') AS TRANSLATED_STRING
FROM DUAL;
YOU MAY ALSO LOOK: - SQL cheat sheet for interview pdf
In this example, the input string is 'HELLO WORLD', and we want to replace all occurrences of the characters 'O' and 'D' with the characters 'X' and 'Y', respectively. The FROM DUAL clause is used to ensure that the query returns a single row, as required by the SELECT statement.
The result of this query would be:
OUTPUT:-
Tags:
ORACLE SQL