Home > Database > Mysql Tutorial > body text

Oracle substr函数用法

WBOY
Release: 2016-06-07 17:34:21
Original
2140 people have browsed it

Oracle substr函数用法取得字符串中指定起始位置和长度的字符串 substr( string, start_position, [ length ] );substr(字符串,

Oracle substr函数用法

取得字符串中指定起始位置和长度的字符串 substr( string, start_position,

substr(字符串,截取开始位置,截取长度) //返回截取的字;

start_position为正时,从左往右获取字符串;

start_position为负时,从右往左获取字符串;

start_position为0时,从字符串开始位置获取字符串;

 

Examples:

1、start_position = 0

SELECT SUBSTR('hello',0,3) FROM dual; --hel
SELECT SUBSTR('hello',0,6) FROM dual; --hello
SELECT SUBSTR('hello',0,0) FROM dual; --null
SELECT SUBSTR('hello',0) FROM dual; --hello

2、start_position > 0

SELECT SUBSTR('hello',1,0) FROM dual; --null
SELECT SUBSTR('hello',1,2) FROM dual; --he
SELECT SUBSTR('hello',1,6) FROM dual; --hello
SELECT SUBSTR('hello',1) FROM dual; --hello

3、start_position

SELECT SUBSTR('hello',-3) FROM dual; --'llo'
SELECT SUBSTR('hello',-1) FROM dual; --'o'
SELECT SUBSTR('hello',-3,2) FROM dual; --'ll'
SELECT SUBSTR('hello',-7) FROM dual; --null

 

相关阅读:

Oracle函数之Replace()

Oracle函数大全

Oracle函数之case和decode的用法区别及性能比较

Oracle函数和存储过程简单实例

Oracle函数 通过秒数或分钟数获取时间段

linux

Related labels:
source:php.cn
Statement of this Website
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 [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!