步骤一:
查询出sql的记录
SELECT T.INSTANCE_NUMBER INST, T.DBID, TO_CHAR(T.STARTUP_TIME, 'YYYY-MM-DD HH24:MI:SS') STARTTIME, TO_CHAR(T.END_INTERVAL_TIME, 'YYYY-MM-DD HH24:MI:SS') ENDTIME, T.SNAP_ID FROM DBA_HIST_SNAPSHOT TWHERE T.BEGIN_INTERVAL_TIME >= TO_DATE('2014-04-27', 'YYYY-MM-DD')ORDER BY T.BEGIN_INTERVAL_TIME
注:时间为输入值,看需要输入
步骤二:
- 方法一sql:
select DBMS_WORKLOAD_REPOSITORY.AWR_REPORT_HTML(&dbid, &inst_num, &b_snapid, &e_snapid) from dual;
- 方法二sql:
select output from table(dbms_workload_repository.awr_report_text(&dbid, &inst_num, &b_snapid, &e_snapid));
参数解释:
1. &dbid DBID(即DBA_HIST_SNAPSHOT.DBID)
2. &inst_num INSTANCE_NUMBER(即DBA_HIST_SNAPSHOT.INSTANCE_NUMBER)
3. &b_snapid snapid(即DBA_HIST_SNAPSHOT.SNAP_ID)的开始id
4. &e_snapid snapid(即DBA_HIST_SNAPSHOT.SNAP_ID)的结束id
例子:
select DBMS_WORKLOAD_REPOSITORY.AWR_REPORT_HTML(1806502892,1,8927,8928) from dual;