-->演示环境 scott@CNMMBO> select * from v$version where rownum<2;
BANNER ---------------------------------------------------------------- Oracle Database 10g Release 10.2.0.3.0 - 64bit Production
-->创建测试表 scott@CNMMBO> create table tb_emp as select * from emp;
-->为测试表创建索引 scott@CNMMBO> create index i_tb_emp_empno on tb_emp(empno);
-->收集统计信息 scott@CNMMBO> exec dbms_stats.gather_table_stats('SCOTT','TB_EMP',cascade=>true);
-->查看索引信息 scott@CNMMBO> @idx_info Enter value for owner: scott Enter value for table_name: tb_emp
Table Name INDEX_NAME CL_NAM CL_POS STATUS IDX_TYP DSCD ------------------------- ------------------------------ -------------------- ------ -------- --------------- ---- TB_EMP I_TB_EMP_EMPNO EMPNO 1 VALID NORMAL ASC
-->查看索引使用情况 -->此时use列为NO,表明索引未被使用到 scott@CNMMBO> @idx_usage_tb Enter value for 1: tb_emp Enter value for 2: all Enter value for 2: all
Table Name INDEX_NAME USE START_MONITORING END_MONITORING ------------------------- ------------------------------ --- ------------------- ------------------- TB_EMP I_TB_EMP_EMPNO NO 03/19/2013 17:43:49
-->实施即席查询 scott@CNMMBO> select empno,ename,job from tb_emp where empno=7788;
EMPNO ENAME JOB ---------- ---------- --------- 7788 SCOTT ANALYST
-->再次查看时USE列已经为YES scott@CNMMBO> @idx_usage_tb Enter value for 1: tb_emp Enter value for 2: all Enter value for 2: all
Table Name INDEX_NAME USE START_MONITORING END_MONITORING ------------------------- ------------------------------ --- ------------------- ------------------- TB_EMP I_TB_EMP_EMPNO YES 03/19/2013 17:43:49
-->禁用索引监控 scott@CNMMBO> alter index I_TB_EMP_EMPNO nomonitoring usage;
Index altered. |