Oracle中檢視建立索引和使用索引的注意點

2021-09-21 19:17:11 字數 614 閱讀 2201

一、檢視和建立索引

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

woshixuye111

oracle中檢視索引 主鍵

select from user indexes where table name upper map eqp onu select from user ind columns where index name idx map eqp onu id 1 清空螢幕 clear screen 2 查詢某...

oracle中的索引檢視

1 建立索引 create index 索引名 on 表名 列名 2 刪除索引 drop index 索引名 3 建立組合索引create index 索引名 on 表名 列名 1,列名2 在資料庫中查詢表名 select fromuser tableswheretable namelike tab...

建立和檢視索引

create table table name 屬性名1 資料型別,屬性名2 資料型別,屬性名3 資料型別,index index name 屬性1 例如 create table t dept deptno int,dname varchar 20 loc varchar 20 index ind...