PostgreSQL RTRIM Function

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

PostgreSQL RTRIM() function

RTRIM() function

The PostgreSQL rtrim function is used to remove spaces( if no character(s) is provided as trimming_text ) or set of characters which are matching with the trimming_text, from the end of a string.

Syntax :

rtrim(<string> [, < trimming_text >])

PostgreSQL Version : 9.3

Pictorial Presentation of PostgreSQL RTRIM() function

 

Example : PostgreSQL RTRIM() function :

In the example below, the matching text is 'best' mention in the second parameter in which 'e','s' and 't' is matching from the end of the first parameter and removed from the string.

SELECT rtrim('rtrimtest', 'best');

Output :

 rtrim
-------
 rtrim
(1 row)

Example 2 :

In the example below, no matching text is specified so the default white spaces have been removed from the end of the string.

SELECT rtrim('rtrim    ');

Output :

 rtrim
-------
 rtrim
(1 row)