> ## Documentation Index
> Fetch the complete documentation index at: https://docs.e6data.com/llms.txt
> Use this file to discover all available pages before exploring further.

# OVERLAY

> Replaces a span of string characters with another string.

<div className="e6-meta"><span className="e6-eyebrow e6-eyebrow--quiet">Scalar function</span></div>

Returns NULL when any supplied operand is NULL.

## Syntax

### Scalar

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
overlay(value PLACING replacement FROM start [FOR count])
```

## Arguments

| Name | Type | Required | Description |
| - | - | - | - |
| value | STRING | Yes | The original string. |
| replacement | STRING | Yes | The text inserted in place of the span. |
| start | INTEGER | Yes | One-based first replaced character. At least 1. |
| count | INTEGER | No | Number of original characters replaced. Use a nonnegative count. Default: The Unicode character count of replacement. |

## Returns

* Type: STRING
* Possible values: The unchanged prefix, replacement, and remaining suffix.
* NULL behavior: Returns NULL when any supplied operand is NULL.

## Properties

| Property | Value |
| - | - |
| Deterministic | Yes |
| Supports window usage | No |
| Exact result | Yes |

## Usage notes

* Positions and replacement counts use Unicode characters rather than UTF-8 bytes. Start beyond the input appends the replacement. Count zero inserts without removing characters.

## Examples

### Example values

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT overlay('Txxxxas' PLACING 'hom' FROM 2 FOR 4) AS "value";
```

| value |
| - |
| Thomas |

### Insert without replacing characters

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT overlay('abcd' PLACING '-' FROM 3 FOR 0) AS inserted;
```

| inserted |
| - |
| ab-cd |

## Limitations

* Start must be at least 1; smaller values raise an error. Use a nonnegative count. A negative count can duplicate parts of the input. These forms cover STRING inputs only.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.