---
title: replace function
description: Learn the syntax of the replace function of the SQL language in Databricks SQL and Databricks Runtime.
canonical_url: https://docs.databricks.com/aws/en/sql/language-manual/functions/replace
---

# `replace` function

**Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) 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

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

> SELECT replace('ABCabc' COLLATE UTF8_LCASE, 'abc', 'DEF');
 DEFDEF
```

## Related functions

* [`overlay` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/overlay.md)
* [`regexp_replace` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/regexp_replace.md)
* [`translate` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/translate.md)
