Oracle Trim Function | PL/SQL TRIM() Function.

0 Flares Twitter 0 Facebook 0 Google+ 0 LinkedIn 0 Buffer 0 Email -- Filament.io 0 Flares ×

See Other related SQL and PLSQL Functions :
>>> DECODE ,MAX ,NVL ,INSTR ,SUBSTR ,TO_DATE ,TO_CHAR ,TO_TIMESTAMP ,GROUP BY,Extract

TRIM function removes all specified characters from the beginning of a string or from the ending of a string.

Syntax:

trim( [ leading or trailing or both  , trim_string ,   stringToTrim )

leading – This removes the ‘trim_string‘ from the beginning of ‘stringToTrim‘.
trailing –This removes the ‘trim_string‘ from the end of ‘stringToTrim‘.
both – This removes the ‘trim_string‘ from the front and end of ‘stringToTrim‘.

By default if there is no choice give oracle will remove ‘trim_string‘ from the front and end of ‘stringToTrim‘.

Examples:

1. Default Options

SQL> select trim ('  abcd ') from dual;

TRIM('ABCD')
abcd
SQL>

2. Option ‘trailing’ Example.

SQL> select trim(trailing 'C' from 'ABC') from dual;

TRIM(TRAILING'C'FROM'ABC')
AB
SQL>

3. Option ‘leading’ Example.

 select trim(leading 'A' from 'ABC') from dual;
TRIM(LEADING'A'FROM'ABC')
BC

4. Option ‘both’ Example

SQL> select trim(both 'A' from 'ABCA') from dual;
TRIM(BOTH'A'FROM'ABCA')
BC

5. Another example for option ‘both’.

SQL> select trim(both 'A' from 'AAAAABCAAAAAAAAA') from dual;
TRIM(BOTH'A'FROM'AAAAABCAAAAAA
BC

Other Functions :>>> DECODE ,MAX ,NVL ,INSTR ,SUBSTR ,TO_DATE ,TO_CHAR ,TO_TIMESTAMP ,GROUP BY,Extract

Related Articles,

Technorati Tags:
, , , , , , , , , , ,

0 Flares Twitter 0 Facebook 0 Google+ 0 LinkedIn 0 Buffer 0 Email -- Filament.io 0 Flares ×

1 thought on “Oracle Trim Function | PL/SQL TRIM() Function.

  1. Pingback: Composite Primary Key in Oracle | SQL and PLSQL

Leave a Reply

Your email address will not be published. Required fields are marked *

Paged comment generated by AJAX Comment Page