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函数 通过秒数或分钟数获取时间段
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号