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);
New on Educative
Learn to Code
Learn any Language as a beginner
Develop a human edge in an AI powered world and learn to code with AI from our beginner friendly catalog
🏆 Leaderboard
Daily Coding Challenge
Solve a new coding challenge every day and climb the leaderboard

Free Resources