Oracle — Replace and Translate function

Replace and Translate function are the most widely asked question in Interview,

Translate:-

Translate function is used to replace the Character from the given string.

Syntax- Translate(‘Column/String’,’source_character’,’target_character’)

In the given String, function is looking for source character if source is there in the given string it will replaced with target character.

Example- here i have taken one word “Welcom Shyamu” and i want to change the a => E and u => T.

Translate Function example

Replace:-

Replace function will replace the whole string from the given word,

Syntax:- replace(‘Column/String’,’source_string’,’target_string’)

Example:- i am taking the same example, but each matching character or word will get replaced by whole string given in target_string.

Replacing W with Namaste
Replace Wel with Namaste
Replace Shyamu with Namaste Ram