函数索引是从8i开始提供的,有了函数索引就可以在索引中使用函数或者表达式了。
例:
SQL> create table t1 (id varchar2(10));
Table created.
SQL> insert into t1 values('a');
1 row created.
SQL> commit;
Commit complete.
SQL>create index ind_t1 on t1(id);
SQL>select * from t1 where upper(id) = ‘test’;
这样的情况下,这个SQL是不会走索引的,因为在ID上面存在函数UPPER,所以只能走全表扫描。
但是利用函数索引,上面的SQL也是可以走索引的。
SQL>drop index ind_t1;
SQL>create index ind_t1 on t1(upper(id));
SQL>analyze table t1 compute statistics for table for all indexes for all indexed columns;
打开AUTOTRACE重新执行上面的SQL,可以发现已经可以走索引了。
版权声明:本文为博主原创文章,未经博主允许不得转载。
oracle
- 上一篇:oracle COALESCE函数
- 下一篇:Oracle使用外部身份认证登录数据库