Welcome 微信登录

首页 / 数据库 / MySQL / Oracle中LIKE语句优化

1。尽量不要使用 like "%%"2。对于 like "%" (不以 % 开头),Oracle可以应用 colunm上的index3。对于 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系统变量函数简介Oracle分析函数学习相关资讯      Oracle教程 
  • Oracle中纯数字的varchar2类型和  (07/29/2015 07:20:43)
  • Oracle教程:Oracle中查看DBLink密  (07/29/2015 07:16:55)
  • [Oracle] SQL*Loader 详细使用教程  (08/11/2013 21:30:36)
  • Oracle教程:Oracle中kill死锁进程  (07/29/2015 07:18:28)
  • Oracle教程:ORA-25153 临时表空间  (07/29/2015 07:13:37)
  • Oracle教程之管理安全和资源  (04/08/2013 11:39:32)
本文评论 查看全部评论 (1)
表情: 姓名: 字数


评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论