Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

Versions available for this page: CUBRID 8.2.1 |  CUBRID 8.3.0 |  CUBRID 8.3.1 |  CUBRID 8.4.0 |  CUBRID 8.4.1 |  CUBRID 8.4.3 |  CUBRID 9.0.0 | 

REPLACE Function

Description

The REPLACE function searches for a character string, search_string, within a given character string, string, and replaces it with a character string, replacement_string. If the string to be replaced, replacement_string is omitted, all search_strings retrieved from string are removed. If NULL is specified as an argument, NULL is returned.

Syntax

REPLACE( string, search_string [, replacement_string ] )

 

string :

? character string

? NULL

 

search_string :

? character string

? NULL

 

replacement_string :

? character string

? NULL

  • string : Specifies the original string. If the value is NULL, NULL is returned.
  • search_string : Specifies the string to be searched. If the value is NULL, NULL is returned.
  • replacement_string : Specifies the string to replace the search_string. If this value is omitted, string is returned with the search_string removed. If the value is NULL, NULL is returned.

Example

--it returns NULL when an argument is specified with NULL value

SELECT REPLACE('12345abcdeabcde','abcde',NULL);

 

======================

  NULL

 

--not only the first substring but all substrings into 'ABCDE' are replaced

SELECT REPLACE('12345abcdeabcde','abcde','ABCDE');

 

======================

  '12345ABCDEABCDE'

 

--it removes all of substrings when replace_string is omitted

SELECT REPLACE('12345abcdeabcde','abcde');

 

======================

  '12345'