RTRIM – Right Trim in oracle

By Santhosh N

This explains how to trim the character(s) specified on the right hand side of the string

Oracle has a function by the name, RTRIM used to remove the specified character(s) from the right hand side of the string.

Syntax: RTRIM(str [, TrimString] )

Here str is the original string and TrimString is the string that needs to be removed from the right hand side of the str. However, this second parameter being optional, if not specified it removes all the trailing spaces from str.

Ex1: RTRIM(‘555egg555’,’555’)
This returns ‘555egg’ as the result.

Ex2: RTRIM(‘EggHead        ’)
This returns ‘EggHead’ as the result.

Ex3: RTRIM(‘EggHeadssss’, ‘s’)
This returns ‘EggHead’ as the result.

Note: RTRIM not only replaces the entire string mentioned as second parameter from the original string but it removes individual occurrences of the characters mentioned in the second parameter.

Ex4: RTRIM(‘EggHead5678’,’0123456789’)
This returns ‘EggHead’ by removing all numbers

Related FAQs

This explains how to trim the character(s) specified on the left hand side of the string
This explains how to replace the part(s) of the string with other string or char
This explains how to convert all the characters to the upper case alphabets
This explains how to convert all the characters to the lower case alphabets
This explains how to find the length of the string in oracle
This explains how to convert first character of the word to the upper case and rest to the lower case.
RTRIM – Right Trim in oracle  (3608 Views)