oracle instr函数 收藏
2011-05-13 20:45
330 查看
oracle instr函数 收藏
在oracle PL/SQL中,instr函数返回string2在string1中出现的位置,语法如下:instr(string1,instring2[,start_position[,nth_appearance]])
string1:被搜索的字符串
string2:在string1里面寻找的字符串
start_position:从string1中开始搜索的位置,这是个可选参数,默认为1。
sting1中第一个字符的位置为1。如果这个参数为一个负数,那么搜索将从string1的末尾开始,并向string1的开始位置进行搜索。
nth_appearance:string2在string1中出现的次数,这是一个可选参数,默认值为1.
注意:如果string2未在string1中出现,那么instr函数的返回值为0。
实例
1.从起始位置开始搜索,第一次出现子串的位置
SQL> select instr('chen_linbo_bobo12082119','bo',1,1) from dual;
INSTR('CHEN_LINBO_BOBO12082119
------------------------------
9
SQL> select instr('chen_linbo_bobo12082119','bo') from dual;
INSTR('CHEN_LINBO_BOBO12082119
------------------------------
9
2.从后往前搜索,第二次出现子串的位置
SQL> select instr('chen_linbo_bobo12082119','bo',-1,1) from dual;
INSTR('CHEN_LINBO_BOBO12082119
------------------------------
14
SQL> select instr('chen_linbo_bobo12082119','bo',-1) from dual;
INSTR('CHEN_LINBO_BOBO12082119
------------------------------
14
3.从指定位置开始搜索
SQL> select instr('chen_linbo_bobo12082119','bo',7,3) from dual;
INSTR('CHEN_LINBO_BOBO12082119
------------------------------
14
SQL> select instr('chen_linbo_bobo12082119','bo',10,3) from dual;
INSTR('CHEN_LINBO_BOBO12082119
------------------------------
0
相关文章推荐
- oracle中类似indexof用法 instr函数
- Oracle中instr函数使用方法
- Oracle 常用SQL技巧收藏
- oracle定时任务(dbms_job)收藏
- 深入了解oracle的高水位(HWM)收藏
- [收藏]ORACLE函数大全
- Oracle的instr函数
- oracle之Flash Recovery Area全面介绍 分类: H2_ORACLE 2013-04-26 15:03 1625人阅读 评论(0) 收藏
- oracle函数整理---instr函数
- oracle instr函数(oracle 用instr 来代替 like)
- oracle中instr函数
- Oracle instr函数 字符串查找
- 收藏:Asp.Net 连接Oracle数据库 出现"找不到 Oracle 客户端和网络组件" 彻底解决方法!
- [收藏]ORACLE函数大全
- oracle文章收藏
- Oracle instr函数
- oracle instr函数
- Oracle 常用SQL技巧收藏
- oracle(收藏)
- Oracle HINT的常见用法(收藏)