Oracle中查看建立索引和使用索引的注意点
发布时间:2020-12-12 13:13:26 所属栏目:百科 来源:网络整理
导读:一、查看和建立索引 select * from user_indexes where table_name = ‘student‘ create index i_student_num on student(num) 二、使用索引的注意点 ①类型匹配 若student中num列是varchar类型。语句select * from student where num = 100 该语句被转化为
一、查看和建立索引 select * from user_indexes where table_name = ‘student‘ create index i_student_num on student(num) 二、使用索引的注意点 ①类型匹配 若student中num列是varchar类型。语句select * from student where num = 100 该语句被转化为select * from student where to_number(num) = 100。该列的索引就失效了。 ②避免索引列參与计算? 索引失效:select * from student where num * 10 > 10000? 索引有效:select * from student where num > 10000 / 10 ③不要对索引列使用IS NULL或IS NOT NULL 原则上对某一个列建立索引的时候,该列就不应该同意为空。 索引失效:select * from student where num is null (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |