The RTRIM Function in Oracle SQL / PLSQL is used to remove the specified characters in a string from the right side.
Syntax for the using the RTRIM Function in Oracle SQL / PLSQL is:
SELECT RTRIM(string_1,[string_2])
FROM table_name;
- string_1 is the string which will be trimmed from the right side
- string_2 is the string which will be matched in string_1 for trimming, it’s an optional parameter, if omitted then RTRIM function will remove all the spaces in string_1 from right side.
Examples:
Using RTRIM Function in Oracle SQL / PLSQL SELECT statement:
1 | SELECT RTRIM( 'Tech Honey' , 'y' ) |
2 | FROM dual; |
Will return ‘Tech Hone’
1 | SELECT RTRIM( 'Tech Honey' , 'Honey' ) |
2 | FROM dual; |
Will return ‘Tech’
1 | SELECT RTRIM( 'Tech Honey ' ) |
2 | FROM dual; |
Will return ‘Tech Honey’
1 | SELECT RTRIM( 'Tech Honey56789' , '0123456789' ) |
2 | FROM dual; |
Will return ‘Tech Honey’
1 | SELECT RTRIM( 'Tech Honey11111' , '1' ) |
2 | FROM dual; |
Will return ‘Tech Honey’