> ## 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.

# REVERSE

> Reverses the characters in a string or the elements in an array.

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

Returns NULL for NULL input.

## Syntax

### String or array

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
reverse(value)
```

## Arguments

Type notation used below:

* T is the array element type: BOOLEAN, TINYINT, SMALLINT, INTEGER, BIGINT, FLOAT, DOUBLE, DECIMAL(p, s), STRING, BINARY, DATE, TIME, TIMESTAMP, ARRAY, MAP or STRUCT.

### String

| Name | Type | Required | Description |
| - | - | - | - |
| value | STRING | Yes | The string to reverse. |

### Array

| Name | Type | Required | Description |
| - | - | - | - |
| value | ARRAY\<T> | Yes | The array to reverse. Nested elements/fields must satisfy the same element-type restrictions. |

## Returns

* Type: STRING for string input; ARRAY\<T> for array input
* Possible values: The input Unicode code points in reverse order.
* NULL behavior: Returns NULL for NULL input.
* Shape: String code points are reversed, or array length and element type are retained.
* Ordering: Reverse input encounter order.

### Array

* Type: ARRAY\<T>
* Possible values: The same elements in reverse order.
* NULL behavior: Returns NULL for NULL array; retains NULL elements.
* Shape: Same length and element type as the input.
* Ordering: Reverse input order.

## Properties

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

## Usage notes

* INTEGER and INT mean the same type; STRING means VARCHAR text. NULL can be used with a supported type. Cast NULL explicitly when its type would otherwise be unclear.

## Examples

### Typical behavior (string)

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT reverse('aé🚀') AS reversed;
```

| reversed |
| - |
| 🚀éa |

### Typical behavior (array)

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT reverse(ARRAY[1, NULL, 2]) AS "value";
```

| value |
| - |
| \[2,null,1] |


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