Uses the specified characters in str3 to replace the characters that are included in str1 from str2. If characters that are included in str1 do not appear in str2, no character is replaced. This function is an additional function of MaxCompute V2.0.
Syntax
string translate(string|varchar <str1>, string|varchar <str2>, string|varchar <str3>)
Return value
A value of the STRING type is returned. If an input parameter is set to null, null is returned.
Examples
Example 1: Use the specified characters in the string
cd
to replace the characters that are included inababab
fromabab
. Sample statement:-- The return value is cdcdcd. select translate('ababab','abab','cd');
Example 2: Use the specified characters in the string
cdefg
to replace the characters that are included inababab
fromabab
. Sample statement:-- The return value is cdcdcd. select translate('ababab','abab','cdefg');
Example 3: An input parameter is set to null. Sample statement:
-- The return value is null. select translate('ababab','cd',null);
Related functions
TRANSLATE is a string function. For more information about functions related to string searches and conversion, see String functions.