Previous Next JavaScript must be enabled to correctly display this content

## rtrim Function

The rtrim function enables you to trim trailing characters from a string.

Syntax

    returnvalue rtrim(source)

    source ::= any*
    returnvalue ::= string

Semantics

source

  The input string that should be trimmed. The trailing spaces in this string are removed. 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 12-58 trim Function

This example demonstrates rtrim function. Notice that the empty spaces at the end are removed but the empty spaces at the beginning are not removed.

Note:

You can use JSON query output mode so that the empty spaces are visible.

    MODE JSON

    SELECT id, rtrim(name) FROM trim_demo

Output:

    {"id":10,"Column_2":"  Peter"}
    {"id":20,"Column_2":"Mary"}
    {"id":30,"Column_2":"  Oliver"}
    {"id":40,"Column_2":"John"}