REVERSE Function [String]

Takes one argument as an input of type BINARY or STRING and returns the specified string with characters listed in reverse order.

Syntax

REVERSE ( expression | uchar_expr )

Parameters

Parameter

Description

expression

A character or binary-type column name, variable, or constant expression of CHAR, VARCHAR, NCHAR, NVARCHAR, BINARY, or VARBINARY type.

Returns

LONG VARCHAR

LONG NVARCHAR

Note: The result data type is a LONG VARCHAR. If you use REVERSE in a SELECT INTO statement, you must have an Unstructured Data Analytics Option license or use CAST and set REVERSE to the correct data type and size.

Example 1

select reverse("abcd")
----
dcba

Example 2

select reverse(0x12345000)
----------
0x00503412

Usage

  • REVERSE, a string function, returns the reverse of expression.

  • If expression is NULL, reverse returns NULL.

  • Surrogate pairs are treated as indivisible and are not reversed.

Permissions

Any user can execute REVERSE.

Standards and Compatibility

  • SQL—Transact-SQL extension to ISO/ANSI SQL grammar.

Related reference
String Operators
LCASE Function [String]
LEFT Function [String]
LOWER Function [String]
REPLACE Function [String]
RIGHT Function [String]
UCASE Function [String]
UPPER Function [String]