RTRIM Function

RTRIM

  • This will trim off unwanted characters from the right sides of string.
  • This will remove all the specific characters from right side of string.

Syntax: rtrim (string [, unwanted_chars])

Ex:

select rtrim('computer','er'), rtrim('computer','ter') from dual;

output

rtrim('computer','er')
-----------------------
comput
rtrim('computer','ter')
--------------------------
compu

RTRIM function in a SQL
RTRIM function in a SQL

some more example

select rtrim('tech   ') from dual;
-----------------------------------
tech
select rtrim('tech   ',' ') from dual;
--------------------------------------
tech
select rtrim('123000','0') from dual;
--------------------------------------
123
select rtrim('123tech123','123') from dual;
--------------------------------------
------
123tech
select rtrim('techxyxzyyy','xyz') from dual;
--------------------------------------
------
tech
select rtrim('tech6372','0123456789') from dual;
--------------------------------------
------
tech

Leave a Reply