forked from docs/doc-exports
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com> Co-authored-by: Su, Xiaomeng <suxiaomeng1@huawei.com> Co-committed-by: Su, Xiaomeng <suxiaomeng1@huawei.com>
6.4 KiB
6.4 KiB
replace
This function is used to replace the part in a specified string that is the same as the string old with the string new and return the result.
If the string has no same characters as the string old, str is returned.
Syntax
replace(string <str>, string <old>, string <new>)
Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
str |
Yes |
STRING |
String to be replaced |
old |
Yes |
STRING |
String to be compared |
new |
Yes |
STRING |
String after replacement |
Return Values
The return value is of the STRING type.
Example Code
The value AA123AA is returned.
select replace('abc123abc','abc','AA');
The value NULL is returned.
select replace('abc123abc',null,'AA');
Parent topic: String Functions