Skip to content

Instantly share code, notes, and snippets.

@davidhooey
Created September 24, 2014 15:40
Show Gist options
  • Save davidhooey/ec95d67e36cf751cec24 to your computer and use it in GitHub Desktop.
Save davidhooey/ec95d67e36cf751cec24 to your computer and use it in GitHub Desktop.
Oracle Generate AWR SQL Report Through SQL
-- Find the dbid, instance_number and begin and end snap_id to be used.
select
snap_id,
dbid,
instance_number,
begin_interval_time,
end_interval_time
from
dba_hist_snapshot
order by
snap_id desc;
-- Plugin dbid, instance_number, begin stap_id, end_snap_id and SQL_ID.
select
output
from
table(
dbms_workload_repository.awr_sql_report_text(
l_dbid => dbid,
l_inst_num => instance_number,
l_bid => begin_interval_time,
l_eid => end_interval_time,
l_sqlid => 'SQL_ID'
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment