oracle学习小结3之索引

来源:互联网 发布:股票网络销售好做吗 编辑:程序博客网 时间:2024/05/15 23:50
  今天归纳索引的常用操作
1) 索引分为B树索引和位图索引
   创建
    create index scott.event_index
  on scott.event(name)
   pctfree 25
storage(initial 500k)
tablespace system;
   如果是位图索引,则create bitmap index .........
2) 查找某个用户的索引的好似用情况,
   select index_name,index_type,tablespace_name,uniqueness,status from dba_indexes where owner='SCOTT';
  查找scott用户基于表和列的信息
    select index_name,table_name,column_name,index_owner,table_owner from dba_ind_columns where table_owner='SCOTT';
3)
重建立和维护索引
   alter index scott.emp_ename_index rebuild
......
  回收索引空间
   alter index scott.emp_ename_idx deallocate unused;
  合拼索引碎片
    alter index scott.emp_ename_idx coalesce;

4) 查看索引使用情况
    alter index emp_ename_idx monitoring usage;
    这里可以打开监督索引的开关
   然后做一些查询后,可以用
    select * from v$object_usage;
 来查看索引使用情况
    再次执行 alter index emp_ename_idx monitoring usage;
则关闭开关.
5) 删除索引
   drop index scott.emp_ename_idx;