replace function

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime

Replaces all occurrences of search with replace.

Syntax

replace(str, search [, replace] )

Arguments

  • str: A STRING expression to be searched.

  • search: A STRING expression to be replaced.

  • replace: An optional STRING expression to replace search with. The default is an empty string.

Returns

A STRING.

If you do not specify replace or is an empty string, nothing replaces the string that is removed from str.

Examples

> SELECT replace('ABCabc', 'abc', 'DEF');
 ABCDEF