最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

Oracle中LIKE语句优化

来源:动视网 责编:小采 时间:2020-11-09 12:09:03
文档

Oracle中LIKE语句优化

Oracle中LIKE语句优化:1。尽量不要使用 like 1。尽量不要使用 like '%%' 2。对于 like '%' (不以 % 开头),Oracle可以应用 colunm上的index 3。对于 like '%…' 的 (不以 % 结尾),可以利用reverse + function index 的形式,变化成 like '%' 建测
推荐度:
导读Oracle中LIKE语句优化:1。尽量不要使用 like 1。尽量不要使用 like '%%' 2。对于 like '%' (不以 % 开头),Oracle可以应用 colunm上的index 3。对于 like '%…' 的 (不以 % 结尾),可以利用reverse + function index 的形式,变化成 like '%' 建测


1。尽量不要使用 like

1。尽量不要使用 like '%%'

2。对于 like '%' (不以 % 开头),Oracle可以应用 colunm上的index

3。对于 like '%…' 的 (不以 % 结尾),可以利用reverse + function index 的形式,变化成 like '%'

建测试表和Index,注意,,重点在于带reverse的function index。同时,一定要使用CBO才行

create table test_like as select object_id,object_name from dba_objects;

-------建立测试表

create index test_like__name on test_like(object_name);

------建立索引

create index test_like__name_reverse on test_like(reverse(object_name));

------建立反向索引

analyze table test_like compute statistics for table for all indexes;

------对表进行分析

都过SQLPLUS连接到数据,一定是SQLPLUS,因为下面有写命令在PLSQL的命令行中不被支持;

set autotrace trace exp

-----设定SQL跟踪

set linesize 2000

-------设定输出宽度

select * from test_like where object_name like 'AS%';

使用了索引

select * from test_like where object_name like '%S';

未使用索引

select * from test_like where reverse(object_name)like reverse('%AS');

使用了索引

文档

Oracle中LIKE语句优化

Oracle中LIKE语句优化:1。尽量不要使用 like 1。尽量不要使用 like '%%' 2。对于 like '%' (不以 % 开头),Oracle可以应用 colunm上的index 3。对于 like '%…' 的 (不以 % 结尾),可以利用reverse + function index 的形式,变化成 like '%' 建测
推荐度:
标签: 数据库 语句 oracle
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top