日期:2014-05-16  浏览次数:20390 次

Oracle索引管理
基础知识:
create table test01
(
   enno number(3),
   enname varchar(20),
   sex  varchar(2),
   age  number(3)
)


1、创建索引
     语法:create index 索引名称 on 表名称(列名称1,列名称2,.......) tablespace 表空间名称;
    例子:create index  ind_enno on test01(enno) tablespace system;
    创建唯一索引:create unique index 索引名称 on 表名称(列名称1,列名称2,......) tablespace 表空间名称
   例子:create unique index ind_age  on test01(age) tablespace system
   创建函数索引:create index 索引名称 on 表名称(函数)
   例子:create index ind_sex on test01 (upper(sex))
2、查询索引
     select  index_name,table_name
     from dba_indexes
     where table_name='TEST01';

3、删除索引
      语法:drop index 索引名称 
      例子:drop index ind_enno;

 4、重命名索引
      语法:alter index 旧索引名称 rename to 新索引名称
       例子:alter  index ind_enno rename to ind_enno1

 5、监控索引的使用
  开启监控:   alter index  索引名称  monitoring usage
  查询使用情况:select * from v$object_usage;
  关闭监控:alter index 索引名 nomonitoring usage
例子:
    alter index ind_enno monitoring usage;
    对test01表进行查