reverse Function

The reverse function returns the characters of the source string in reverse order, where the string is written beginning with the last character first. For example, the reverse order for "welcome" is "emoclew".

Syntax

returnvalue reverse(source)

source ::= any*
returnvalue ::= string

Semantics

source

The input string for which the characters should be reversed. This argument is implicitly cast to a sequence of strings.

returnvalue

Returns NULL if the source argument is NULL.

Returns NULL if the source argument is an empty sequence or a sequence with more than one item.

Example 11-24 reverse Function

In this example, the first name is displayed along with its reverse order.

SELECT firstname, reverse(firstname) FROM users;
 +-----------+----------+
 | firstname | Column_2 |
 +-----------+----------+
 | John      | nhoJ     |
 | Peter     | reteP    |
 | Mary      | yraM     |
 +-----------+----------+
  翻译: