在表内容已经定的情况下 输入值 通过函数所得的输出值要对应固定的。输入值不能是变量
========================
instr函数怎么建立函数索引?
create index 索引名 on 表名(instr(各个参数))
-
追问
-
CREATE INDEX CUSTNAME_TEST ON TEST (INSTR(CUST_NAME,'???')),关键是‘???’部分是个变量,可能输入张三,也可能输入李四,我建索引的时候用什么值呢?
-
回答
-
这个不是固定值就搞不定了。
===================
instr函数怎么建立函数索引???
create table test (name varchar2(30));
insert into test values('I love Oracle');
insert into test values('I love Oracle');
insert into test values('I love Oracle');
insert into test values('I hate Oracle');
insert into test values('I hate Oracle');
insert into test values('I hate Oracle');
create index idx_test on test(instr(name,'h'));
select /*+index(test)*/* from test where instr(name,'h')=2;
SELECT STATEMENT, GOAL = CHOOSE 耗费=1 基数=1 字节=17
TABLE ACCESS BY INDEX ROWID 对象所有者=YAOYP 对象名称=TEST 耗费=1 基数=1 字节=17
INDEX RANGE SCAN 对象所有者=YAOYP 对象名称=IDX_TEST 耗费=1 基数=1
我是想用instr代替like的功能,所以不能制定要包含的字符串,这样要怎么建立索引,
比如上面这个例子,我有的时候找的是'h'有的时候找的是'c',要包含的字符串不确定的这种情况。
那肯定不行啊。你想想index的结构就知道不可能像你这样用来了。
如果要全文搜索,Oracle自己有工具的,好像Oracle Text
=======================
create index idx_lot_id on rpt_lotinfo a inner join
(select a.lot_id from rpt_lotinfo a,rpt_wipstep b where a.lot_id = b.lotnum group by a.lot_id) b (instr(a.lot_id,b.lot_id)); 请问我这个索引这样写可不可以? |
![]() |
#9 得分:0
回复于: 2009-10-21 12:35:15
估计楼主加的索引类型不对啊!可以尝试:
1、函数索引。 2、我给个列子(好像10g中才有)。 create index mytext_id_x on mytext(thetext) indextype is CTXSYS.CONTEXT; select * from mytext where contains(thetext,'my')>0; |