ORACLE/PLSQL: TRIM FUNCTION

来源:互联网 发布:电商美工的前景 编辑:程序博客网 时间:2024/06/08 10:01

The Oracle/PLSQL TRIM function removes all specified characters either from the beginning or the ending of a string.

ORACLE TRIM SYNTAX

The syntax for the Oracle/PLSQL TRIM function is:

TRIM( [ leading | trailing | both [ trim_character ] string1 )

PARAMETERS OR ARGUMENTS

leading - remove trim_string from the front of string1.

trailing - remove trim_string from the end of string1.

both - remove trim_string from the front and end of string1.

trim_character is the character that will be removed from string1. If this parameter is omitted, the TRIM function will remove all leading and trailing spaces fromstring1.

string1 is the string to trim.

NOTE

If you do not choose a value for the first parameter (leadingtrailingboth), the TRIM function will remove trim_string from both the front and end of string1.

APPLIES TO

The TRIM function can be used in the following versions of Oracle/PLSQL:

  • Oracle 12c, Oracle 11g, Oracle 10g, Oracle 9i, Oracle 8i


ORACLE TRIM EXAMPLE

Let's look at some Oracle TRIM function examples and explore how you would use the TRIM function in Oracle/PLSQL.

For example:

TRIM('   tech   ')would return 'tech'TRIM(' '  from  '   tech   ')would return 'tech'TRIM(leading '0' from '000123')would return '123'TRIM(trailing '1' from 'Tech1')would return 'Tech'TRIM(both '1' from '123Tech111')would return '23Tech'
0 0
原创粉丝点击