oracle like函数 介绍与优化
来源:互联网 发布:淮安悠迅网络 编辑:程序博客网 时间:2024/06/06 02:49
oracle like函数 介绍与优化
原文连接:http://www.itemperor.com/a/SQL/68.html
用法:
like 'A%' -- 字符串以A 开头like '%A' -- 字符串以A 结尾
like '%A%'-- 字符串以 包含A ,(不管出现在字符串的什么位置)
表 table1 包含字段 name
有时候我们用到的如下 语句,
select * from table1 where name like '%AB%' or name like '%20%' or name like '%30%'or name like '%12414%';
但是查询起来特别慢,这个时候我们怎么去优化它
1.确定 我们需求字符串的准确位置,譬如说我们 只要AB 开头,CD 结尾的字符,我们可以写成 name like 'AB%' or name like '%CD'
2.数字大小比较,像这种有数字的,我们可以 以写成 to_number(name)>=20 and to_number(name)<=30
3.instr instr(name,'AB') >0 ,这个通过角标表的位置可以提高效率 --- instr() 函数返回字符串 角标所在的位置,没有返回0
4.正则表示式: 如果仅仅取包含数字和字母 可以这样写
where regexp_like(name,'[0-9]+|[A-Z]+')
或者:
where regexp_like(name,'[[:alpha:]]+|[[:digit:]]+')
--- regexp_like(): 字符串截取函数用于正则表达式 oracle 10g 函数, + :表示一个或者多个,| 表示或者的意思
--[[:alpha:]] 任何字母。
--[[:digit:]] 任何数字。
5. 建立索引,给字段 name 建立个索引提高查询的效率
阅读全文
0 0
- oracle like函数 介绍与优化
- 再谈Oracle like优化
- Oracle like '%...%' 优化
- Oracle like语句优化
- Oracle like 优化
- Oracle like语句优化
- oracle中like的优化
- ORACLE中LIKE语句优化
- ORACLE中LIKE语句优化
- oracle中like的优化
- ORACLE中LIKE语句优化
- oracle 全文索引优化like
- Oracle like '%xxx%'优化笔记。
- 索引与优化like查询
- 索引与优化like查询
- 索引与优化like查询
- 索引与优化like查询
- 索引与优化like查询
- chosen插件的使用
- 字符串和日期之间的转换
- python list里面是dict时排序
- How to craw the Info of BiliBIli with python in Parallel
- CentOS 7.x下安装MySQL错误(ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password:)
- oracle like函数 介绍与优化
- 环信3.0自定义扩展消息
- itop4412 uboot 学习详细记录四丶Exynos4412 编译Makefile的配置文件config.mk分析)
- STM32使用SWO引脚调试
- 136.Single Number
- 简述:为什么硅胶按键要使用镭雕工艺?
- #研发解决方案介绍#Tracing(鹰眼)
- php读取目录及子目录下所有文件名的方法
- Spring framework(3):IoC(1) IoC 容器&上下文对象