SQLite’s REPLACE function is used to search and replace a substring within a string. The function takes three arguments:


REPLACE(string, search_string, replacement_string)

string is the input string to be searched and replaced.
search_string is the substring to be searched for.
replacement_string is the string to replace the search_string with.

The REPLACE function returns a new string where all occurrences of the search_string in the string have been replaced with the replacement_string.


Here is an example:

SELECT REPLACE('Hello, World!', 'World', 'SQLite');

The output of this query would be:

Hello, SQLite!

Note that the REPLACE function is case-sensitive. To perform a case-insensitive search and replace, you can use the LIKE operator with the REPLACE function:

SELECT REPLACE('Hello, World!', 'world', 'SQLite') COLLATE NOCASE;

The COLLATE NOCASE clause makes the LIKE operator case-insensitive.

In addition, it’s worth noting that the REPLACE function does not modify the original string. Instead, it returns a new string with the replacements made.