监控索引使用
---以下是相关PROCEDURE: CREATE OR REPLACE PROCEDURE start_monitor_index IS Cursor cur1 is select OWNER,INDEX_NAME from dba_indexes di where di.owner like '%BJ'; p_rows cur1%ROWTYPE; p_str varchar2(200); begin open cur1; loop fetch cur1 into p_rows; exit when cur1%NOTFOUND; p_str:='alter index '||p_rows.owner||'.'||p_rows.index_name||' MONITORING USAGE'; execute immediate p_str; --dbms_output.put_line(p_str); end loop; close cur1; dbms_output.put_line('finish'); COMMIT; END; CREATE OR REPLACE PROCEDURE stop_monitor_index IS Cursor cur1 is select OWNER,INDEX_NAME from dba_indexes di where di.owner like '%BJ'; p_rows cur1%ROWTYPE; p_str varchar2(200); begin open cur1; loop fetch cur1 into p_rows; exit when cur1%NOTFOUND; p_str:='alter index '||p_rows.owner||'.'||p_rows.index_name||' NOMONITORING USAGE'; execute immediate p_str; --dbms_output.put_line(p_str); end loop; close cur1; dbms_output.put_line('finish'); COMMIT; END; -----特殊 create or replace view v$object_usage (index_name, table_name, monitoring, used, start_monitoring, end_monitoring) as select io.name, t.name, decode(bitand(i.flags, 65536), 0, 'NO', 'YES'), decode(bitand(ou.flags, 1), 0, 'NO', 'YES'), ou.start_monitoring, ou.end_monitoring from sys.obj$ io, sys.obj$ t, sys.ind$ i, sys.object_usage ou where io.owner# = userenv('SCHEMAID') and i.obj# = ou.obj# and io.obj# = ou.obj# and t.obj# = i.bo#
作者:czjie
出处:http://www.cnblogs.com/czjie/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。