oracle substr()函数

本文详细介绍了 Oracle/PLSQL 中 SUBSTR 函数的使用方法,包括语法、参数说明及多个示例,帮助读者更好地理解如何从字符串中抽取子串。

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

In Oracle/PLSQL, thesubstrfunctions allows you to extract a substring from a string.

The syntax for thesubstrfunction is:

substr( string, start_position, [ length ] )

stringis the source string.

start_positionis the position for extraction. The first position in the string is always 1.

lengthis optional. It is the number of characters to extract. If this parameter is omitted,substrwill return the entire string.

Note:

Ifstart_positionis 0, thensubstrtreatsstart_positionas 1 (ie: the first position in the string).

Ifstart_positionis a positive number, thensubstrstarts from the beginning of the string.

Ifstart_positionis a negative number, thensubstrstarts from the end of the string and counts backwards.

Iflengthis a negative number, thensubstrwill return a NULL value.

Applies To:

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

For example:

substr('_yeexunOn优快云',8) char_return 'On优快云' substr('_yeexunOn优快云',10) char_return '优快云' substr('_yeexunOn优快云',8,2) char_return 'On' substr('_yeexunOn优快云',-4,4) char_return '优快云' substr('_yeexunOn优快云',0,7) char_return '_yeexun' substr('_yeexunOn优快云',1,7) char_return '_yeexun' substr('_yeexunOn优快云',0,1) char_return '_' substr('_yeexunOn优快云',1,1) char_return '_' substr('_yeexunOn优快云',0,2) char_return '_y' substr('_yeexunOn优快云',1,2) char_return '_y'

原文:http://www.techonthenet.com/oracle/functions/substr.php

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值