oracle数据库中表t_staff的staff_num字段上已经建立了索引,下面哪条语句能够正确的使用到该索引?B
A. select * from t_staff where staff_num <> 10000
B. select * from t_staff where staff_num + 2000 > 10000
C. select * from t_staff where staff_num is not null
D. select * from t_staff where to_char(staff_num) = '3145'请各位高手解答下,(1)数据库建立索引需要什么条件?
(2)建立完怎样查询索引,需要注意什么问题?
(3)上面答案是B,为什么?
A. select * from t_staff where staff_num <> 10000
B. select * from t_staff where staff_num + 2000 > 10000
C. select * from t_staff where staff_num is not null
D. select * from t_staff where to_char(staff_num) = '3145'请各位高手解答下,(1)数据库建立索引需要什么条件?
(2)建立完怎样查询索引,需要注意什么问题?
(3)上面答案是B,为什么?
C.违反了NULL原则,有IS NULL或者IS NOT NULL不走索引。
D.尽量不在WHERE字句用函数,否则要建立函数索引。可以参考http://wenku.baidu.com/view/363a9e2758fb770bf78a5572.html
经常查询使用的列,并且性能慢的情况下建立索引,根据实际需求建立不同的索引,复合索引,单列索引,位图索引等2:查询表上索引
非分区:select * from dba_indexes where
分区:select * from dba_ind_partition where
要注意索引是否有效,如果为INVLIDATE 的话,要重建索引3:要理解这个就要深入理解索引的概念
一般来说,索引键值无法直接使用的话则基本上不能正确使用索引了