閱讀344 返回首頁    go 阿裏雲 go 技術社區[雲棲]


Oracle中查看建立索引和使用索引的注意點

一、查看和建立索引
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

最後更新:2017-04-03 20:19:25

  上一篇:go JS操作剪貼板
  下一篇:go "0x00a1bdb3" 指令引用的 "0x00000001" 內存。該內存不能為 "read"。