What is REVERSE() in SQL?

The REVERSE() function reverses the order of a string.

Figure 1 shows a visual representation of the REVERSE() function.

Figure 1: Visual representation of REVERSE() function

Syntax

REVERSE(string)

Parameters

The REVERSE() function takes a string as a parameter.

Return value

REVERSE() returns the string sent as a parameter in the reverse order.

This function returns NULL if NULL is sent as a parameter.

Example

-- simple string
SELECT REVERSE('HELLO');
-- palindrome string
SELECT REVERSE('LEVEL');
-- NULL
SELECT REVERSE(NULL);

Free Resources