数据库函数索引为什么不起作用(300万条记录)

gold_future 2004-11-07 09:44:19
建索引 create index myIndex on myTable (LOWER(NAME))

查询 select * from myTable where UPPER(NAME)='中国'


...全文
284 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
gold_future 2004-11-08
  • 打赏
  • 举报
回复
已解决
select /* index 表名 索引名*/ myName from myTable wherre lower(myName )='abcd'
tonymanager 2004-11-08
  • 打赏
  • 举报
回复
Where条件中,如果=左边的字段有函数,索引是不起作用的.
如: To_Char(Name),upper(Name)
Croatia 2004-11-08
  • 打赏
  • 举报
回复
to: biliky()
你这样的做法是不对的,和搂主的提问的初衷,不一致了。
zhaokeke2004 2004-11-08
  • 打赏
  • 举报
回复
楼主为什么中文也要用upper函数?
qiyousyc 2004-11-08
  • 打赏
  • 举报
回复
应该是select * from myTable where NAME=LOWER('中国');

系统会自动找到并使用索引的。
biliky 2004-11-08
  • 打赏
  • 举报
回复
try as follows:

select * from myTable where NAME=LOWER('中国');
LGQDUCKY 2004-11-08
  • 打赏
  • 举报
回复
可能也与优化器有关,因为中文没有大小写之分,你试下英文,然后在看下

执行计划,LOWER(NAME)='中国'
zmgowin 2004-11-08
  • 打赏
  • 举报
回复
在不考虑优化器的情况下,要创建基于函数的索引

首先要对用户赋query rewrite权限
grant query rewrite to user_name;
然后需要设置环境变量
query_rewrite_enabled=true
query_rewrite_integrity=trusted

最后再创建基于函数的索引,否则是不能生效的
wupangzi 2004-11-08
  • 打赏
  • 举报
回复
你怎么判断出来,他不起作用呢?
gold_future 2004-11-08
  • 打赏
  • 举报
回复
ss
gold_future 2004-11-07
  • 打赏
  • 举报
回复
写错了
建索引 create index myIndex on myTable (LOWER(NAME))

查询 select * from myTable where LOWER(NAME)='中国'

17,377

社区成员

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

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