Skip to main content

REVERSE

Description​

The REVERSE function is used to reverse the order of characters in a string or the order of elements in an array.

Syntax​

REVERSE( <seq> )

Parameters​

ParameterDescription
<seq>The string or array whose order needs to be reversed.

Return Value​

Returns the string or array with the reversed order. Special cases:

  • If any Parameter is NULL, NULL will be returned.

Examples​

SELECT reverse('hello');
+------------------+
| REVERSE('hello') |
+------------------+
| olleh |
+------------------+
SELECT reverse(['hello', 'world']);
+-----------------------------+
| reverse(['hello', 'world']) |
+-----------------------------+
| ["world", "hello"] |
+-----------------------------+