Friday, 23 February 2024

Replace Function in Oracle

In Oracle, the REPLACE function is used to replace all occurrences of a substring within a string with another substring. It searches a string for a specified substring and replaces it with another substring.


Here's the syntax of the REPLACE function in Oracle:


REPLACE(original_string, old_substring, new_substring)


- original_string: The string in which to perform the replacement.

- old_substring: The substring to be replaced.

- new_substring: The substring to replace the occurrences of old_substring.


Example:

SELECT REPLACE('hello world', 'world', 'universe') AS replaced_string FROM dual;


This will return 'hello universe', indicating that all occurrences of the substring 'world' have been replaced with 'universe' in the original string 'hello world'.

No comments:

Post a Comment