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

# `reverse` 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

Returns a reversed string or an array with reverse order of elements.

## Syntax

```
reverse(expr)
```

## Arguments

* `expr`: A `STRING` or `ARRAY` expression.

## Returns

The result type matches the type of `expr`.

## Examples

```sql
> SELECT reverse('Spark SQL');
 LQS krapS
> SELECT reverse(array(2, 1, 4, 3));
 [3,4,1,2]
```

## Related functions
