Friday, September 27, 2013

generate awr report for database


// generate awr report for database ( not instance) for period 8 -9 am

conn sys/manager@&1 as sysdba
variable begin_snap_id number
variable end_snap_id number
variable db_id number
begin
  select distinct snap_id into :begin_snap_id from dba_hist_snapshot
  where BEGIN_INTERVAL_TIME like '01-SEP-13 07%AM%';
  :end_snap_id := :begin_snap_id + 1;
  select DBID into :db_id from v$database;
end;
/
define  num_days     = 1;
define  db_name      = &1;
define  dbid         = :db_id;
define  begin_snap   = :begin_snap_id;
define  end_snap     = :end_snap_id;
define  report_type  = 'html';
define  instance_numbers_or_ALL = '1,2,3'
define  time         = 8am
define  report_name  = /tmp/AWR/awr_&1._&time..html
@@?/rdbms/admin/awrgrpti
exit