如何用到索引的问题

dabtd 2006-04-07 07:26:22
表A中的列test_name 建了索引,如果是:
select * from A where test_name like 'ab%' 则可以用到索引,如果是:
select * from A where test_name like '%ab'则不能用到索引,如果才能让后者也能用到呢?
...全文
113 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
liuyi8903 2006-04-09
  • 打赏
  • 举报
回复
test_name
是的.利用反向索引.
但是前提是.既然是反向.你的字符也要求反着来写:)

创建完后把索引分析一下.还要看看你返回的结果有多大.
dabtd 2006-04-09
  • 打赏
  • 举报
回复
如果是test_name这列,我试了好像不行。
dabtd 2006-04-09
  • 打赏
  • 举报
回复
create index i_name on aa(id) reverse;

=========================================
你这里的aa(id)是指的哪一列?
liuyi8903 2006-04-07
  • 打赏
  • 举报
回复
for example:

before:select * from A where test_name like 'ab%'

create index i_name on aa(id) reverse;

after: select * from A where test_name like '%ba' ;
liuyi8903 2006-04-07
  • 打赏
  • 举报
回复
create index i_name on table(col) reverse

or

using first_rows hint

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧