Home > SQL, Technical > Difference between replace and translate in SQL Oracle

Difference between replace and translate in SQL Oracle

January 20, 2012

Replaces…changes the string by string

select replace(‘karuvachi’,’chi’,’yan’) from dual;

Output:

REPLACE(‘KARUVACHI’,’CHI’,’YAN’)
——————————–
karuvayan

translate…changes the character by character

select translate(‘karuvachi’,’vac’,’vec’) from dual;

Output:

TRANSLATE(‘KARUVACHI’,’VAC’,’ABC’)
———————————-
kbruabchi

Note: the “b” second character also changed.

Advertisements
Categories: SQL, Technical
%d bloggers like this: