Difference between REPLACE and TRANSLATE in SQL?

Replace will replace the character or string with the given character/string for every occurrence of the character/string.
Translate will replace the character with another character given not by the string/multiple characters

Case 1:

SELECT
REPLACE(‘Jack and Jue’,’J’,’Bl’) replace_str,
TRANSLATE(‘Jack and Jue’,’J’,’Bl’) translate_str
FROM DUAL;

Case 2:

SELECT
REPLACE(‘Jack and Jue’,’J’,”) replace_str,
TRANSLATE(‘Jack and Jue’,’J’,”) translate_str
FROM DUAL;

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top