replace( STRING, string_to_replace, replacement_string) replaces string_to_replace by replacement_string as a whole.
All Bs would be replaced by O. SQL> select replace('ABC PBR XBZ','B','O') from dual; REPLACE('AB ----------- AOC POR XOZ
There wont be any change since APX string is not there.
SQL> select replace('ABC PBR XBZ','APX','MNO') from dual; REPLACE('AB ----------- ABC PBR XBZ
Translate(STRING, string_to_replace, replacement_string) replaces the 1st character in the string_to_replace with the 1st character in the replacement_string. Then it will replace the 2nd character in the string_to_replace with the 2nd character in the replacement_string, and so on.
All Bs would be replaced by Os.
SQL> select translate('ABC PBR XBZ','B','O') from dual; TRANSLATE(' ----------- AOC POR XOZ
All As would be replaced by M, all Ps would be replaced by N and all Os would be replaced by Os.
SQL> select translate('ABC PBR XBZ','APX','MNO') from dual; TRANSLATE(' ----------- MBC NBR OBZ
|