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:
SELECT RTRIM('Tech Honey', 'y') FROM dual;
Will return ‘Tech Hone’
SELECT RTRIM('Tech Honey', 'Honey') FROM dual;
Will return ‘Tech’
SELECT RTRIM('Tech Honey ') FROM dual;
Will return ‘Tech Honey’
SELECT RTRIM('Tech Honey56789', '0123456789') FROM dual;
Will return ‘Tech Honey’
SELECT RTRIM('Tech Honey11111', '1') FROM dual;
Will return ‘Tech Honey’