Can any one tell me the difference between replace function & translate function of Oracle?
I read somewhere that replace makes the changes in database permanent where translate does not, is it correct?
Can any one show the query which will prove that replace does changes permanently in database?
The difference between REPLACE and TRANSLATE:
Here’s some examples:
REPLACE works like this:
gives:
Just the word ‘peanuts’ is replaced with ‘tomatoes’. It’s case sensitive so ‘Peanuts’ isn’t replaced.
TRANSLATE works like this:
All spaces are changed to underscores and all periods are changed to bangs!
Neither TRANSLATE or REPLACE update the database. They just change the value
in a statement. Of course, you can use that value to update the database if
you want. For example:
The table is still the same:
If you want to change the table, put it in an UPDATE or INSERT statement,
such as:
Now it’s changed:
Now if you want to fix ‘Peanuts’ too, you can use REGEXP_REPLACE.