The TRIM Function : TRIM « Character String Functions « Oracle PL/SQL Tutorial






  1. TRIM removes characters from the left or right ends of a string or both ends.
  2. LTRIM and RTRIM trim characters from the left or right ends of strings.
  3. TRIM supercedes both of these.

The general syntax of TRIM is: TRIM ([where] [trim character] FROM subject string)

  1. The optional 'where' is one of the keywords "leading," "trailing," or "both."
  2. If the optional 'trim character' is not present, then blanks will be trimmed.
  3. 'Trim character' may be any character.
  4. The word FROM is necessary only if where or trim character is present.
SQL> SELECT TRIM (' AAA       ') FROM dual;

TRI
---
AAA

SQL>








11.15.TRIM
11.15.1.The TRIM Function
11.15.2.TRIM (both ' ' from ' String with blanks ')
11.15.3.Characters rather than spaces are trimmed
11.15.4.TRIM(leading 'F' from 'FABCDEF')
11.15.5.TRIM(trailing 'r' from 'Real water')
11.15.6.TRIM from both sides
11.15.7.Nested trim
11.15.8.TRIM Leading and Trailing Zeroes
11.15.9.Triming leading 'H' from employee last name
11.15.10.match trimmed string