閱讀801 返回首頁    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 12:56:20

  上一篇:go 如何查看Memcache 運行狀態 stats(Status) —— Memcache Telnet 接口
  下一篇:go 九度題目1088:剩下的樹