================原版官方解释==============================>
TRANSLATE ( 'expr' , 'from_string' , 'to_string' )
TRANSLATE returns expr with all occurrences of each character in from_string replaced by its corresponding character in to_string. Characters in expr that are not in from_string are not replaced. If expr is a character string, then you must enclose it in single quotation marks. The argument from_string can contain more characters than to_string. In this case, the extra characters at the end of from_string have no corresponding characters in to_string. If these extra characters appear in char, then they are removed from the return value. You cannot use an empty string for to_string to remove all characters in from_string from the return value. Oracle Database interprets the empty string as null, and if this function has a null argument, then it returns null. TRANSLATE provides functionality related to that provided by the REPLACE function. REPLACE lets you substitute a single string for another single string, as well as remove character strings. TRANSLATE lets you make several single-character, one-to-one substitutions in one operation. This function does not support CLOB data directly. However, CLOBs can be passed in as arguments through implicit data conversion. Examples The following statement translates a book title into a string that could be used (for example) as a filename. The from_string contains four characters: a space, asterisk, slash, and apostrophe (with an extra apostrophe as the escape character). The to_string contains only three underscores. This leaves the fourth character in the from_string without a corresponding replacement, so apostrophes are dropped from the returned value. SELECT TRANSLATE('SQL*Plus User''s Guide', ' */''', '___') FROM DUAL; TRANSLATE('SQL*PLUSU -------------------- SQL_Plus_Users_Guide ================粗略的汉字解释==============================> TRANSLATE ( 'char' , 'from_string' , 'to_string' ) TRANSLATE返回将from_string中的每个字符替换为to_string中的相应字符以后的string。 TRANSLATE是REPLACE所提供的功能的一个超集。如果from_string比to_string长,那么在from_string中而不在to_string中的额外字符将从char中被删除,因为它们没有相应的替换字符。to_string不能为空。Oracle将空字符串解释为NULL,并且如果TRANSLATE中的任何参数为NULL,那么结果也是NULL。 举个例子-- select translate('123abc','2dc','4e') from dual; 因为from_string和to_string的位置是一一对应的,2对应4,d对应e,c没有对应的值,所以c应该会被删除。 所以例子的字符里的2会替换为4, d因为字符串里没有,所以不作替换, c由于没有对应的替换字符,所以字符串里的c会被删除 那么可以得出,结果是 143ab