## Syntax ```mermaid %%{init: { 'theme': 'base', 'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' }, 'themeVariables': { 'fontSize': '11px', 'fontFamily': 'Arial' } }}%% flowchart LR Start((START)) --> REPLACE[REPLACE]:::quoted REPLACE --> End((END)) ``` ## Purpose The `REPLACE` SQL function changes a given text by replacing all occurrences from an ordered list of texts by their associated replacement texts. See also [[TRANSLATE]] and [[REGEXP_REPLACE]]. Parameters: - Input (`varchar2`): the text to change. - Old text 1 (`varchar2`): the text to be replaced. - New text 1 (`varchar2`): the replacement text. - Old text n (optional, `varchar2`): additional texts to be replaced. - New text n (optional, `varchar2`): additional replacement texts. Returns: A text with all old texts replaced by their new text in the order they occur in the list. ## Examples The following example replaces `b` by `z` in `abc`: ```sql select replace('abc', 'b', 'z') ------------------- azc ``` The following example removes `b` from `abc` by replacing it with an empty text, and replaces `c` by `d`: ```sql select replace('abc', 'b', '', 'c', 'd') ------------------- ad ``` The following example leaves the input unchanged since the old text is `null`: ```sql select replace('abcd', null, 'z') ------------------- abcd ```