|
在测试函数索引,发现在一个表的CHAR字段上建立函数索引之后,检索结果出现了变化
先建立个测试表,使用CHAR类型
create table test (
a char(10),
b char(10)
);
insert into test values ('111','111');
insert into test values ('222','222');
commit;
SQL> select * from test;
A B
---------- ----------
111 111
222 222
SQL> select * from test where a = '111';
A B
---------- ----------
111 111
SQL> create index test_index on test (substr(a,1,1));
Index created
SQL> select * from test;
A B
---------- ----------
111 111
222 222
SQL> select * from test where a = '111';
A B
---------- ----------
困惑ing......
再试
SQL> select /*+ INDEX(test) */ * from test where a= '111';
A B
---------- ----------
SQL> select /*+ FULL(test) */ * from test where a= '111';
A B
---------- ----------
111 111
崩溃鸟。。。。。。
换成varchar2类型再看
drop table test;
create table test (
a varchar2(10),
b char(10)
);
insert into test values ('111','111');
insert into test values ('222','222');
commit;
SQL> select * from test;
A B
---------- ----------
111 111
222 222
SQL> select * from test where a = '111';
A B
---------- ----------
111 111
SQL> create index test_index on test (substr(a,1,1));
Index created
SQL> select * from test;
A B
---------- ----------
111 111
222 222
SQL> select /*+ INDEX(test) */ * from test where a= '111';
A B
---------- ----------
111 111
SQL> select /*+ FULL(test) */ * from test where a= '111';
A B
---------- ----------
111 111
SQL> select * from v$version;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
再次败给oracle,这应该是个bug吧? |
|