Syntax format: TRANSLATE (expr,from_string,to_string)
sql> SELECT TRANSLATE (' ab hello cde ', ' abcde ', ' 123456 ') as New_str from DUAL;
New_str
---------
12 Hello 345
from_string and to_sting in characters, corresponding to character one by one replaces.
sql> SELECT TRANSLATE (' Ab Hello Cade ', ' abcde ', ' 123456 ') as New_str from DUAL;
New_str
----------
12 Hello 3145
You can see that the character ' a ' is also replaced with ' 1 ' in the back, and Chinese characters are not replaced.
if to_string is empty, it is returned as a null value.
sql> SELECT TRANSLATE (' Ab Hello Cade ', ' abcde ', ') as New_str from DUAL;
N
-
if the to_string corresponds to a position where there are no characters, deleting the characters listed in the from_string will be erased.
sql> SELECT TRANSLATE (' Ab Hello Cade ', ' 1abcde ', ' 1 ') as new_str from DUAL;
New_
----
hello.