Search and Replace in Oracle
Suppose you want to update String value of a column based on search and replace, you can use Replace function of Oracle. It takes 3 parameters as follows.
1. Column name you are interested in to find and replace values of
2. Search String
3. Replacement String
for example, you can update the values of all names if they contain 'Ram' in themselves by 'Shyam'.
update user_account set user_name = replace(user_name, 'Ram','Shyam');
This will first search all user_names for 'Ram' and then updates them with String 'Shyam';
4 comments:
the above syntax doesn't work. this is the correct syntax:
UPDATE table_name
SET name = REPLACE(name, 'oldname', 'newname')
WHERE name like '%oldname%';
Thx!
Works finde and saved me some time :-)
Thanks a lot it worked for me awesome !!!
Post a Comment