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.
![](https://support.huaweicloud.com/intl/en-us/sqlreference-dli/public_sys-resources/note_3.0-en-us.png)
If the value of any input parameter is NULL, NULL is returned.
Example Code
The value AA123AA is returned.
select replace('abc123abc','abc','AA');
The value NULL is returned.
select replace('abc123abc',null,'AA');
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot