Oracle中的instr()函数 详解及应用
1)instr()函数的格式 (俗称:字符查找函数)
格式一:instr( string1, string2 ) / instr(源字符串, 目标字符串)
格式二:instr( string1, string2 [, start_position [, nth_appearance ] ] ) / instr(源字符串, 目标字符串, 起始位置, 匹配序号)
解析:string2 的值要在string1中查找,是从start_position给出的数值(即:位置)开始在string1检索,检索第nth_appearance(几)次出现string2。
注:在Oracle/PLSQL中,instr函数返回要截取的字符串在源字符串中的位置。只检索一次,也就是说从字符的开始到字符的结尾就结束。
2)实例
格式一
1 select instr('helloworld','l') from dual; --返回结果:3 默认第一次出现“l”的位置 2 select instr('helloworld','lo') from dual; --返回结果:4 即:在“lo”中,“l”开始出现的位置 3 select instr('helloworld','wo') from dual; --返回结果:6 即“w”开始出现的位置
格式二
1 select instr('helloworld','l',2,2) from dual; --返回结果:4 也就是说:在"helloworld"的第2(e)号位置开始,查找第二次出现的“l”的位置 2 select instr('helloworld','l',3,2) from dual; --返回结果:4 也就是说:在"helloworld"的第3(l)号位置开始,查找第二次出现的“l”的位置 3 select instr('helloworld','l',4,2) from dual; --返回结果:9 也就是说:在"helloworld"的第4(l)号位置开始,查找第二次出现的“l”的位置 4 select instr('helloworld','l',-1,2) from dual; --返回结果:4 也就是说:在"helloworld"的倒数第1(d)号位置开始,往回查找第二次出现的“l”的位置 5 select instr('helloworld','l',-2,2) from dual; --返回结果:4 和第四个一样 6 select instr('helloworld','l',2,3) from dual; --返回结果:9 也就是说:在"helloworld"的第2(e)号位置开始,查找第三次出现的“l”的位置 7 select instr('helloworld','l',-2,3) from dual; --返回结果:3 也就是说:在"helloworld"的倒数第2(l)号位置开始,往回查找第三次出现的“l”的位置
注:MySQL中的模糊查询 like 和oracle中的instr()函数有同样的查询效果; 如下所示:
select * from tableName a where name like '%helloworld%'; select * from tableName a where instr(name,'helloworld')>0; --这两条语句的效果是一样的
3)实例截图
1、
2、
3、
4、
5、
6、
7、
8、
Oracle中的instr()函数 详解及应用相关推荐
- Oracle中的instr()函数详解及应用
转自:点这里看作者 1)instr()函数的格式 (俗称:字符查找函数) INSTR( string, substring [, start_position [, th_appearance ] ] ...
- Oracle数据库的instr()函数详解。
instr(sourceString,destString,start,appearPosition) sourceString:目标字段,需要进行匹配的字段 destString:匹配字段,用来与目 ...
- Oracle中的substr()函数 详解及应用
1)substr函数格式 (俗称:字符截取函数) 格式1: substr(string string, int a, int b); 格式2:substr(string string, int a ...
- java实现instr_Oracle的instr()函数详解
Oracle的instr()函数详解 1.instr()函数的格式 (俗称:字符查找函数) 格式一:instr( string1, string2 ) // instr(源字符串, 目标字符串) 格式 ...
- python getattr_Python中的getattr()函数详解:
标签:Python中的getattr()函数详解: getattr(object, name[, default]) -> value Get a named attribute from an ...
- timm 视觉库中的 create_model 函数详解
timm 视觉库中的 create_model 函数详解 最近一年 Vision Transformer 及其相关改进的工作层出不穷,在他们开源的代码中,大部分都用到了这样一个库:timm.各位炼丹师 ...
- python input函数详解_对Python3中的input函数详解
下面介绍python3中的input函数及其在python2及pyhton3中的不同. python3中的ininput函数,首先利用help(input)函数查看函数信息: 以上信息说明input函 ...
- Python中的bbox_overlaps()函数详解
Python中的bbox_overlaps()函数详解 想要编写自己的目标检测算法,就需要掌握bounding box(边界框)之间的关系.在这之中,bbox_overlaps()函数是一个非常实用的 ...
- 在oracle中使用存储过程,如何在ORACLE中使用JAVA存储过程(详解)
如何在Oracle中使用Java存储过程 (详解) 一.如何缔造java存储过程? 通常有三种步骤来缔造java存储过程. 1.使用oracle的sql语句来缔造: e.g.使用create or r ...
最新文章
- 阻塞队列BlockingQueue 学习
- apache php mysql是长连接吗_php关于mysql长连接问题
- linux6下kdump的配置
- Redis分布式锁的正确实现方式(Java版)
- oracle sql字符拆分字符串函数,oracle-是否有在PL / SQL中拆分字符串的功能?
- mysql增删改查 工具类_Hibernate增删改查数据库之二工具类
- 可变对象 vs 不可变对象(Python)
- Java之StringBuffer使用方法
- 功能强大的手绘Web图表组件-RoughViz
- html5华文行楷字体代码,html5 支持的字体样式
- Xweibo与第三方站点单点登录配置
- java 调用科大讯飞 实现会议录音,语音转写会议既要功能
- 西安2020EC游记
- 洛谷每日三题之第六天
- The credentials mode of request initiated by the XMLHttpRequest is controlled by the withCredentials
- 如何删除在System中打开的iso文件
- 关于resharper激活
- Required request body is missing: public错误
- 第九天 (集合 ArrayList)
- linux 共享文件夹 安装,linux – Vagrant并在共享文件夹中安装包
热门文章
- Unity3D研究院之鼠标控制角色移动与奔跑示例
- 爱默生EC20系列PLC与组态软件的连接
- 借助Packet Capture实现无Root抓请求
- unrar e 解压命令报错:
- 【机器学习】基于PCA/LDA的数据降维和可视化(二维+三维)
- 北京大学计算机技术应用硕士分数线,北京大学2018年考研复试基本分数线已发布...
- 哈工大深圳计算机学硕读几年,2019往届三跨哈工大(深圳校区)学硕考研经验分享...
- 深入了解HBASE架构
- GitHub发卡系统zfaka配置历程
- 如果A不可逆,如何求AX=B的解