快捷生出awr和awrsql報告

浪漫雙魚發表於2011-06-07

    每次呼叫awrrpt及awrsqrpt生成報告的互動很是鬱悶,今天檢視了下awrrpt.sql檔案,把直接呼叫方式找出來了,不要互動方式感覺就是爽啊,特別是用awrsqrpt去分析大量sql的時候,挨個互動肯定是讓人崩潰的,指令碼看下文:

prompt----------list snap-----------
prompt  顯示snap 

prompt------------------------

col snap_id for 999999999;
col startup_time for a30;
col begin_interval_time for a30;
col end_interval_time for a30;
select snap_id,startup_time,begin_interval_time,end_interval_time from dba_hist_snapshot order by snap_id;

prompt----------awr-----------
prompt select output from table(dbms_workload_repository.awr_report_text(db_id,instance_number,begin_snap,end_snap,8));
prompt------------------------

column instance_number  heading "instance_number"  new_value instance_number  format 99999;
column dbid      heading "dbid"     new_value dbid      format 9999999999;
select dbid  from v$database;
select instance_number from v$instance;
select output from table(dbms_workload_repository.awr_report_text(&&dbid,&&instance_number,1281,1282,8));

prompt---------awrsqrpt---------
prompt select output from table(dbms_workload_repository.awr_sql_report_text(db_id,instance_number,begin_snap,end_snap,sql_id,8));
prompt------------------------

column instance_number  heading "instance_number"  new_value instance_number  format 99999;
column dbid      heading "dbid"     new_value dbid      format 9999999999;
select dbid  from v$database;
select instance_number from v$instance;
select output from table(dbms_workload_repository.awr_sql_report_text(&&dbid,&&instance_number,1281,1282,'687tkw3kgrybw',8));

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/11088128/viewspace-697296/,如需轉載,請註明出處,否則將追究法律責任。

相關文章