PostgreSQL 18 reference · String Functions
PostgreSQL RTRIM() Function
Remove spaces, or any characters you list, from the end (right side) of a string only.
PostgreSQL 18
Syntax
rtrim(string, characters)
Parameters
| Parameter | Description |
|---|---|
string |
The input text. |
characters optional |
Characters to remove; spaces by default. |
Return value
Text.
Examples
SELECT '[' || rtrim('right ') || ']' AS result;
Output
result --------- [right] (1 row)
Run this on your computer — see “Get Started” for setup.
SELECT rtrim('https://example.com///', '/') AS url;
Output
url --------------------- https://example.com (1 row)
Run this on your computer — see “Get Started” for setup.
In other languages
RTRIM()· SQLite
Related
TRIM()· Remove spaces, or characters you list, from the start, end or both ends of a string. btrim() is the function form.LTRIM()· Remove spaces, or characters you list, from the start of a string only.- SQL String Functions · tutorial