Home  >  Article  >  Database  >  sql substr()函数用法详细

sql substr()函数用法详细

WBOY
WBOYOriginal
2016-06-07 17:46:154038browse

文章是介绍了oracle中和plsql中的substr()字符串截取函数的用法,有需要的同学可以参考一下。

文章是介绍了oracle中和plsql中的substr()字符串截取函数的用法,有需要的同学可以参考一下。

语法

 代码如下 复制代码

substr( string, start_position, [ length ] )


字符串是源字符串。

start_position是提取的位置。字符串中的第一个位置始终为1。

length  可选的。它是提取的字符数。如果省略该参数,SUBSTR将返回整个字符串。

Applies To:

 代码如下 复制代码

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


实例

 代码如下 复制代码

substr('This is a test', 6, 2) would return 'is'
substr('This is a test', 6) would return 'is a test'
substr('TechOnTheNet', 1, 4) would return 'Tech'
substr('TechOnTheNet', -3, 3) would return 'Net'
substr('TechOnTheNet', -6, 3) would return 'The'
substr('TechOnTheNet', -8, 2) would return 'On'

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn