DB2 REPLACE Function: Syntax & Usage Guide
The REPLACE function in DB2 database can be used to replace a substring within a string. Its syntax is as follows:
REPLACE(string, search_string, replacement_string)
Among them:
- String: The string that will undergo replacement operations.
- search_string: the substring to be replaced.
- new_string to be replaced with in the string
For example, if we have a string “Hello World” and we want to replace the “World” with “Universe”, we can use the following SQL statement:
SELECT REPLACE('Hello World', 'World', 'Universe') AS new_string;
This will return the result as “Hello Universe”.