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.
Uses of RTRIM() Function
- Remove Trailing Spaces: Clean up trailing spaces from the end of a string.
- Remove Specific Characters: Remove specified characters from the end of a string.
- Data Sanitization: Ensure that strings are trimmed of unwanted trailing characters for consistent data storage and processing.
- String Formatting: Prepare strings for display by removing extraneous characters from the end.
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.
Code:
SELECT rtrim('rtrimtest', 'best');
Sample 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.
Code:
SELECT rtrim('rtrim ');
Sample Output:
rtrim ------- rtrim (1 row)
Previous: RPAD function
Next: SPLIT_PART function
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/PostgreSQL/rtrim-function.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics