w3resource

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.

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

Oracle RTRIM function 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

Previous: RPAD
Next: SOUNDEX



Follow us on Facebook and Twitter for latest update.