Oracle RTRIM function
Description
The Oracle 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.
If you do not specify triming_text, then it defaults to a single blank. If a string is a character literal, then you must enclose it in single quotation marks.
Uses of Oracle RTRIM Function
- Basic Right Trimming: Remove trailing spaces from the end of a string.
- Character-Specific Trimming: Remove specified characters from the end of a string.
- Data Cleaning: Clean up strings by removing unwanted trailing characters or spaces.
- Formatting Query Output: Ensure consistent formatting by trimming unnecessary trailing characters.
Syntax:
RTRIM(string [, trimming_text ])
Parameters:
Name | Description | Data Types |
---|---|---|
string | The string to trim the characters from the right-hand side. | CHAR, VARCHAR2, NCHAR, NVARCHAR2, CLOB, or NCLOB |
trimming_text | String which is used for trimming. | CHAR, VARCHAR2, NCHAR, NVARCHAR2, CLOB, or NCLOB |
Return Value Type
VARCHAR2
Applies to
Oracle 12c, Oracle 11g, Oracle 10g, Oracle 9i, Oracle 8i
Pictorial Presentation
Examples : Oracle RTRIM function
The following example RTRIM all the right-most occurrences as specified.
SQL> SELECT RTRIM('w3r ') "Str" FROM DUAL;
Output:
Str --- w3r
SQL>
SQL> SELECT RTRIM(' w3r ') "Str" FROM DUAL;
Output:
Str ----- w3r
SQL> SELECT RTRIM('000985000','0') "Str" FROM DUAL;
Output:
Str ------ 000985
SQL> SELECT RTRIM('9850101','01') "Str" FROM DUAL;
Output:
Str --- 985
SQL> SELECT RTRIM('W3R123486','0123456789') "Str" FROM DUAL;
Output:
Str --- W3R
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/oracle/character-functions/oracle-rtrim-function.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics