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

被折叠的 条评论
为什么被折叠?



