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,
- Oracle Decode Function | Use PLSQL DECODE function to handle NULL and default values
- SQL: MAX Function | SQL Max examples
- SQL GROUP BY Statement | SQL GROUP BY Clause examples
- NVL | Oracle/PLSQL: NVL Function
- SUBSTR functions | Oracle/PLSQL: Substr Function
- Oracle/PLSQL: Instr Function |INSTR functions |Case sensitive search
- Oracle pl/sql error: ORA-06502: PL/SQL: numeric or value error:
- Oracle pl/sql error: ORA-06512
- ORA-12154: TNS:could not resolve the connect identifier specified
- Oracle timestamp format milliseconds| Oracle Date format
Technorati Tags:
TRIM, Oracle Trim Function, PLSQL TRIM Function, DECODE, MAX, NVL, INSTR, SUBSTR, TO_DATE, TO_CHAR, TO_TIMESTAMP, GROUP BY
Pingback: Composite Primary Key in Oracle | SQL and PLSQL