ORACLE/PLSQL: TRIM FUNCTION

本文介绍了 Oracle/PLSQL 中的 TRIM 函数,该函数用于从字符串的开头或结尾移除指定字符。文章详细解释了 TRIM 函数的语法、参数及用法,并提供了多个示例帮助理解。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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'
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值