> ## Documentation Index
> Fetch the complete documentation index at: /documents/llms.txt
> Use this file to discover all available pages before exploring further.

# rtrim

> Removes the trailing spaces or specified characters from the end (right) of the str argument.

Removes the trailing spaces or specified characters from the end (right) of the `str` argument. Removing specified characters are supported from StarRocks 2.5.0.

## Syntax

```Haskell theme={null}
VARCHAR rtrim(VARCHAR str[, VARCHAR characters]);
```

## Parameters

`str`: required, the string to trim, which must evaluate to a VARCHAR value.

`characters`: optional, the characters to remove, which must be a VARCHAR value. If this parameter is not specified, spaces are removed from the string by default. If this parameter is set to an empty string, an error is returned.

## Return value

Returns a VARCHAR value.

## Examples

Example 1: Remove the three trailing spaces from the string.

```Plain Text theme={null}
mysql> SELECT rtrim('   ab d   ');
+---------------------+
| rtrim('   ab d   ') |
+---------------------+
|    ab d             |
+---------------------+
1 row in set (0.00 sec)
```

Example 2: Remove specified characters from the end of the string.

```Plain Text theme={null}
MySQL > SELECT rtrim("xxabcdxx", "x");
+------------------------+
| rtrim('xxabcdxx', 'x') |
+------------------------+
| xxabcd                 |
+------------------------+
```

## References

* [trim](/documents/4.2/sql-reference/sql-functions/string-functions/trim.md)
* [ltrim](/documents/4.2/sql-reference/sql-functions/string-functions/ltrim.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.