Oracle instr() 字符查找函数
instr()函数的格式 (俗称:字符查找函数)
格式一:instr( string1, string2 ) / instr(源字符串, 目标字符串)
格式二:instr( string1, string2 [, start_position [, nth_appearance ] ] ) / instr(源字符串, 目标字符串, 起始位置, 匹配序号)
解析:string2 的值要在string1中查找,是从start_position给出的数值(即:位置)开始在string1检索,检索第nth_appearance(几)次出现string2。
例子:
格式一
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,1) from dual; --返回结果:9 也就是说:在"helloworld"的倒数第1(d)号位置开始,往回查找第一次出现的“l”的位置
5 select instr('helloworld','l',-2,2) from dual; --返回结果:4 也就是说:在"helloworld"的倒数第2(l)号位置开始,往回查找第二次出现的“l”的位置
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”的位置
转载自:https://www.cnblogs.com/dshore123/p/7813230.html
Oracle instr() 字符查找函数的更多相关文章
- Oracle的字符替换函数translate用法
参考文档如下:http://www.banping.com/2009/05/18/oracle_function_translate/ Oracle提供了一个字符替换函数translate,不同于re ...
- Oracle substr() 字符截取函数
1.substr函数格式 (俗称:字符截取函数) 格式1: substr(string string, int a, int b); 格式2:substr(string string, int a ...
- 《oracle每日一练》oracle截取字符的函数
转载 在Oracle中 可以使用instr函数对某个字符串进行判断,判断其是否含有指定的字符. 在一个字符串中查找指定的字符,返回被查找到的指定的字符的位置. 语法: instr(sourceStri ...
- Oracle的字符连接函数 concat 和 || 的区别
总结:concat 只能连接两个字符串,|| 可以连接多个
- ORACLE 常用字符函数
ORACLE 常用字符函数1 ASCII(arg1)返回参数arg1的十进制数字表示.如果数据库设置为ASCII,则采用的是ASCII码字符.如果设置为EBCDIC,则采用的是EBCDIC字符 sel ...
- oracle instr函数(oracle 用instr 来代替 like)
oracle instr函数 对于instr函数,我们经常这样使用:从一个字符串中查找指定子串的位置.例如: SQL> select instr('Oracle','or') position ...
- Oracle instr函数与SqlServer charindex的区别
INSTR(C1,C2[,I[,J]]) [功能]在一个字符串中搜索指定的字符,返回发现指定的字符的位置; [说明]多字节符(汉字.全角符等),按1个字符计算 [参数] C1 被搜索的字符串 ...
- 数据库Oracle字符处理函数
练习字符处理函数(数据库表都是从1开始),我们用到一张"伪表" dual: dual 表:dual 是一张只有一个字段,一行记录的表.dual 表也称之为'伪表',因为他不存储主题 ...
- oracle常用字符函数
字符函数: concat:(字符连接函数) --字符连接 select concat('con','cat') from dual; select 'co'||'nc'||'at' from dual ...
随机推荐
- AS3放大镜工具类
package { import flash.display.Bitmap; import flash.display.BitmapData; import flash.display.Display ...
- 【洛谷 P3966】 [TJOI2013]单词(AC自动机,差分)
把单词连起来,中间插入间隔符,同 #include <cstdio> #include <queue> #include <cstring> using names ...
- Keepalived简单理解
Keepalived Keepalived是一个基于VRRP协议来实现的LVS服务高可用方案,可以利用其来避免单点故障.一个LVS服务会有2台服务器运行Keepalived,一台为主服务器(MASTE ...
- vue+vant-UI框架写的购物车的复选框全选和反选
购物车页面的设计图 商品的列表 代码: <ul v-if="shoppingListData.rows.length"> <li v-for="(ite ...
- javascript 常见的面试题---数组 && 算法
网上汇总而来的题目. 第一题: 用 JavaScript 写一个函数,输入 int 型(正整数),返回整数逆序后的字符串.如:输入整型 1234,返回字符串“4321”. 要求必须使用递归函数调用,不 ...
- Node.js学习(第二章:node核心模块--fs)
前言 Node.js中赋予了JavaScript很多在浏览器中没有的能力,譬如:文件读写,创建http服务器等等,今天我们就来看看在node中怎样用JavaScript进行文件的读写操作. 读文件 我 ...
- Centos6.10编译安装php-7.1.12并安装redis模块
1.服务器初始化 yum update -yyum install epel-release -yyum install gcc gcc-c++ wget lsof lrzsz telnet -y 2 ...
- 修改网口速度mii-tool和ethtool
mii-tool # mii-tool -F 100baseTx-FD media: 100baseT4, 100baseTx-FD, 100baseTx-HD, 10baseT-FD, 10base ...
- 在Linux主机使用命令行批量删除harbor镜像
在Linux主机使用命令行批量删除harbor镜像 脚本使用说明: 此脚本不是万能脚本,根据自身环境要调整很多 能用harbor的域名就不要用IP 脚本前半部分可以套用,后半部分需一步一步试错,结合 ...
- 使用protobuf (proto3, C++和go语言)
在这里,我先讲述C++使用protobuf,之后,会补充使用go语言使用protobuf. 使用protobuf需要有如下步骤: 在.proto文件中定义消息(message)格式. 使用protob ...