1. 創(chuàng)建索引
create index 索引名 on 表名(列名);
2. 刪除索引
drop index 索引名;
3. 創(chuàng)建組合索引
create index 索引名 on 表名(列名1,,列名2);
4.查詢索引
oracle中表的索引信息存在
user_indexes和user_ind_columns兩張表里面
- user_indexes: 系統(tǒng)視圖存放是索引的名稱以及該索引是否是唯一索引等信息;
- user_ind_columns:統(tǒng)視圖存放的是索引名稱,對應(yīng)的表和列等;
基本查詢:
select * from user_indexes;
select * from user_ind_columns t;
-- 1. 根據(jù)索引名,查詢表索引字段
select * from user_ind_columns where index_name='索引名';
-- 2. 根據(jù)表名,查詢一張表的索引
select * from user_indexes where table_name='表名'
-------------------
關(guān)聯(lián)查詢:
select i.index_name,
i.index_type,
i.table_owner,
i.table_name,
i.uniqueness,
i.tablespace_name,
c.column_name,
c.column_position,
c.column_length
from
user_indexes i, user_ind_columns c
where
i.index_name = c.index_name;