oracle中substr的用法是什么

   2025-03-15 3890
核心提示:在Oracle中,SUBSTR函数用于从字符串中提取子字符串。语法:SUBSTR(string, start_position, [length])参数说明:string:要

在Oracle中,SUBSTR函数用于从字符串中提取子字符串。

语法:

SUBSTR(string, start_position, [length])

参数说明:

string:要提取子字符串的字符串。

start_position:指定开始提取的位置,从 1 开始计数。

length:可选参数,指定要提取的子字符串的长度。如果省略该参数,则提取从 start_position 开始到字符串末尾的所有字符。

示例:

提取字符串中的子字符串:

SELECT SUBSTR(‘Hello World’, 7) FROM dual;

结果:‘World’

提取字符串中指定长度的子字符串:

SELECT SUBSTR(‘Hello World’, 7, 5) FROM dual;

结果:‘World’

提取字符串中指定长度并在开始位置偏移的子字符串:

SELECT SUBSTR(‘Hello World’, 7, 3) FROM dual;

结果:‘Wor’

 
 
更多>同类维修知识
推荐图文
推荐维修知识
点击排行
网站首页  |  关于我们  |  联系方式  |  用户协议  |  隐私政策  |  网站留言