ACE Director Alum Daniel Morgan, founder of Morgan's Library, is scheduling
complimentary technical Workshops on Database Security for the first 30
Oracle Database customers located anywhere in North America, EMEA, LATAM, or
APAC that send an email to
asra_us@oracle.com. Request a Workshop for
your organization today.
Purpose
API for managing the Workload Repository and performing operations such as managing snapshots and baselines for ASH and AWR reports.
AUTHID
DEFINER
Background Process
MMON - Automatic data purging every 7 days by default
Constants
Name
Data Type
Value
MAX_INTERVAL
NUMBER
52560000 (100 years)
MIN_INTERVAL
NUMBER
10 (10 minutes)
MAX_RETENTION
NUMBER
52560000 (100 years)
MIN_RETENTION
NUMBER
1440 (1 day)
Data Types
CREATE OR REPLACE NONEDITIONABLE TYPE SYS.AWRRPT_HTML_TYPE
AS OBJECT (output VARCHAR2(8000 CHAR));
CREATE OR REPLACE NONEDITIONABLE TYPE SYS.AWRRPT_HTML_TYPE_TABLE
AS TABLE OF AWRRPT_HTML_TYPE;
CREATE OR REPLACE NONEDITIONABLE TYPE SYS.AWRRPT_TEXT_TYPE
AS OBJECT (output VARCHAR2(80 CHAR));
CREATE OR REPLACE NONEDITIONABLE TYPE SYS.AWRRPT_TEXT_TYPE_TABLE
AS TABLE OF AWRRPT_TEXT_TYPE;
CREATE OR REPLACE NONEDITIONABLE TYPE SYS.AWRRPT_ROW_TYPE
AS OBJECT (
num_dfn AWRRPT_NUM_ARY,
vch_dfn AWRRPT_VCH_ARY,
clb_dfn AWRRPT_CLB_ARY);
CREATE OR REPLACE NONEDITIONABLE TYPE SYS.AWRRPT_INSTANCE_LIST_TYPE
AS TABLE OF NUMBER;
Dependencies
AWRBL_DETAILS_TYPE
AWR_PDB_BASELINE
DBMS_SWRF_INTERNAL
AWRBL_DETAILS_TYPE_TABLE
AWR_PDB_BASELINE_DETAILS
DBMS_SWRF_LIB
AWRBL_METRIC_TYPE
AWR_PDB_SNAPSHOT
DBMS_SWRF_REPORT_INTERNAL
AWRBL_METRIC_TYPE_TABLE
AWR_PDB_SYSMETRIC_SUMMARY
DBMS_UMF
AWRDRPT_TEXT_TYPE
AWR_ROOT_BASELINE
DBMS_UMF_PROTECTED
AWRDRPT_TEXT_TYPE_TABLE
AWR_ROOT_BASELINE_DETAILS
DBMS_WORKLOAD_CAPTURE_I
AWRRPT_HTML_TYPE
DBA_HIST_BASELINE
DBMS_WORKLOAD_REPLAY_I
AWRRPT_HTML_TYPE_TABLE
DBA_HIST_BASELINE_DETAILS
DBMS_WRR_INTERNAL
AWRRPT_INSTANCE_LIST_TYPE
DBMS_ASH_INTERNAL
DBMS_XPLAN
AWRRPT_TEXT_TYPE
DBMS_ASSERT
MGMT_BSLN_INTERVALS
AWRRPT_TEXT_TYPE_TABLE
DBMS_AWR_WAREHOUSE_SERVER
PLITBLM
AWRSQRPT_TEXT_TYPE
DBMS_AWR_WAREHOUSE_SOURCE
PRVT_AWR_VIEWER
AWRSQRPT_TEXT_TYPE_TABLE
DBMS_MANAGEMENT_PACKS
V$INSTANCE
AWR_CDB_BASELINE
DBMS_REPORT
WRM$_WR_CONTROL
AWR_CDB_BASELINE_DETAILS
DBMS_STANDARD
XMLTYPE
Documented
Yes
First Available
10.1
Initialization Parameters
_awr_cdbperf_threshold
_awr_mmon_cpuusage
_awr_restrict_mode
_awr_corrupt_mode
_awr_mmon_deep_purge_all_expired
_awr_sql_child_limit
_awr_disabled_flush_tables
_awr_mmon_deep_purge_interval
_flush_plan_in_awr_sql
_awr_flush_threshold_metrics
_awr_pdb_registration_enabled
_remote_awr_enabled
_awr_flush_workload_metrics
_awr_remote_target_dblink
Security Model
Owned by SYS with EXECUTE granted to DBA, OEM_MONITOR, and SYSUMF_ROLE roles
Source
{ORACLE_HOME}/rdbms/admin/dbmsawr.sql
-- also the following scripts create the AWR schema objects
{ORACLE_HOME}/rdbms/admin/catawr.sql
{ORACLE_HOME}/rdbms/admin/catawrpd.sql
{ORACLE_HOME}/rdbms/admin/catawrtb.sql
{ORACLE_HOME}/rdbms/admin/catawrwv.sql
-- all must be run as SYSDBA
Routine to add a colored SQL ID. If an SQL ID is colored, it will always be captured in every snapshot, independent of its level of activities (i.e. does not have to be a TOP SQL).
Capturing will occur if the SQL is found in the cursor cache at snapshot time.
dbms_workload_repository.add_colored_sql(
sql_id IN VARCHAR2,
dbid IN NUMBER DEFAULT NULL);
Return the ASH Spot report in text format as one column of VARCHAR2(80)
dbms_workload_repository.ash_global_report_html(
l_dbid IN NUMBER,
l_inst_num IN VARCHAR2,
l_btime IN DATE,
l_etime IN DATE,
l_options IN NUMBER DEFAULT 0,
l_slot_width IN NUMBER DEFAULT 0,
l_sid IN NUMBER DEFAULT NULL,
l_sql_id IN VARCHAR2 DEFAULT NULL,
l_wait_class IN VARCHAR2 DEFAULT NULL,
l_service_hash IN NUMBER DEFAULT NULL,
l_module IN VARCHAR2 DEFAULT NULL,
l_action IN VARCHAR2 DEFAULT NULL,
l_client_id IN VARCHAR2 DEFAULT NULL,
l_plsql_entry IN VARCHAR2 DEFAULT NULL,
l_data_src IN NUMBER DEFAULT 0,
l_container IN VARCHAR2 DEFAULT NULL)
RETURN awrrpt_html_type_table PIPELINED;
conn sys@pdbdev as sysdba
SELECT dbid
FROM v$database;
SELECT * FROM TABLE(dbms_workload_repository.ash_global_report_html(428676178, 1, SYSDATE-1, SYSDATE, l_wait_class=>'Other'));
Returns the ASH Spot report in html format as one column of VARCHAR2(500)
dbms_workload_repository.ash_global_report_text(
l_dbid IN NUMBER,
l_inst_num IN VARCHAR2,
l_btime IN DATE,
l_etime IN DATE,
l_options IN NUMBER DEFAULT 0,
l_slot_width IN NUMBER DEFAULT 0,
l_sid IN NUMBER DEFAULT NULL,
l_sql_id IN VARCHAR2 DEFAULT NULL,
l_wait_class IN VARCHAR2 DEFAULT NULL,
l_service_hash IN NUMBER DEFAULT NULL,
l_module IN VARCHAR2 DEFAULT NULL,
l_action IN VARCHAR2 DEFAULT NULL,
l_client_id IN VARCHAR2 DEFAULT NULL,
l_plsql_entry IN VARCHAR2 DEFAULT NULL,
l_data_src IN NUMBER DEFAULT 0,
l_container IN VARCHAR2 DEFAULT NULL)
RETURN awrdrpt_text_type_table PIPELINED;
conn sys@pdbdev as sysdba
SELECT dbid
FROM v$database;
SELECT * FROM TABLE(dbms_workload_repository.ash_global_report_text(428676178, 1, SYSDATE-1/24, SYSDATE, l_wait_class=>'Other'));
Return the ASH (analytics) active report in HTML format
dbms_workload_repository.ash_report_analytics(
dbid IN NUMBER := NULL,
inst_id IN NUMBER := NULL,
begin_time IN DATE,
end_time IN DATE,
report_level IN VARCHAR2 := NULL,
filter_list IN VARCHAR2 := NULL)
RETURN CLOB;
SELECT dbid
FROM v$database;
SELECT dbms_workload_repository.ash_report_analytics(1863203691, 1, SYSDATE-1/24, SYSDATE)
FROM dual;
dbms_workload_repository.ash_report_html(
l_dbid IN NUMBER,
l_inst_num IN NUMBER,
l_btime IN DATE,
l_etime IN DATE,
l_options IN NUMBER DEFAULT 0,
l_slot_width IN NUMBER DEFAULT 0,
l_sid IN NUMBER DEFAULT NULL,
l_sql_id IN VARCHAR2 DEFAULT NULL,
l_wait_class IN VARCHAR2 DEFAULT NULL,
l_service_hash IN NUMBER DEFAULT NULL,
l_module IN VARCHAR2 DEFAULT NULL,
l_action IN VARCHAR2 DEFAULT NULL,
l_client_id IN VARCHAR2 DEFAULT NULL,
l_plsql_entry IN VARCHAR2 DEFAULT NULL)
RETURN awrrpt_html_type_table PIPELINED;
SELECT dbid
FROM v$database;
SELECT inst_id
FROM gv$instance;
SELECT sample_time
FROM gv$active_session_history
ORDER BY 1;
set pagesize 0
set linesize 121
spool c:\temp\ash_rpt.html
SELECT * FROM TABLE(dbms_workload_repository.ash_report_html(428676178, 1, SYSDATE-30/1440, SYSDATE-1/1440));
dbms_workload_repository.ash_report_text(
l_dbid IN NUMBER,
l_inst_num IN NUMBER,
l_btime IN DATE,
l_etime IN DATE,
l_options IN NUMBER DEFAULT 0,
l_slot_width IN NUMBER DEFAULT 0,
l_sid IN NUMBER DEFAULT NULL,
l_sql_id IN VARCHAR2 DEFAULT NULL,
l_wait_class IN VARCHAR2 DEFAULT NULL,
l_service_hash IN NUMBER DEFAULT NULL,
l_module IN VARCHAR2 DEFAULT NULL,
l_action IN VARCHAR2 DEFAULT NULL,
l_client_id IN VARCHAR2 DEFAULT NULL,
l_plsql_entry IN VARCHAR2 DEFAULT NULL)
RETURN awrrpt_text_type_table PIPELINED;
SELECT dbid
FROM v$database;
SELECT inst_id
FROM gv$instance;
SELECT sample_time
FROM gv$active_session_history
ORDER BY 1;
set pagesize 0
set linesize 121
spool c:\temp\ash_rpt.html
SELECT * FROM TABLE(dbms_workload_repository.ash_report_text(428676178, 1, SYSDATE-30/1440, SYSDATE-1/1440));
This table function displays the AWR Compare Periods Report in HTML format as one column of VARCHAR2(5000)
dbms_workload_repository.awr_diff_report_html(
dbid1 IN NUMBER,
inst_num1 IN NUMBER,
bid1 IN NUMBER,
eid1 IN NUMBER,
dbid2 IN NUMBER,
inst_num2 IN NUMBER,
bid2 IN NUMBER,
eid2 IN NUMBER)
RETURN awrrpt_html_type_table PIPELINED;
This table function displays the AWR Compare Periods Report in TEXT format. The pipelined output is one column of VARCHAR2(240).
dbms_workload_repository.awr_diff_report_text(
dbid1 IN NUMBER,
inst_num1 IN NUMBER,
bid1 IN NUMBER,
eid1 IN NUMBER,
dbid2 IN NUMBER,
inst_num2 IN NUMBER,
bid2 IN NUMBER,
eid2 IN NUMBER)
RETURN awrdrpt_text_type_table PIPELINED;
Displays the Gobal AWR Compare Periods Report in HTML format. The pipelined output is one column of VARCHAR2(1500).
Overload 1
dbms_workload_repository.awr_global_diff_report_html(
dbid1 IN NUMBER,
inst_num1 IN AWRRPT_INSTANCE_LIST_TYPE,
bid1 IN NUMBER,
eid1 IN NUMBER,
dbid2 IN NUMBER,
inst_num2 IN AWRRPT_INSTANCE_LIST_TYPE,
bid2 IN NUMBER,
eid2 IN NUMBER)
RETURN awrrpt_html_type_table PIPELINED;
TBD
Overload 2
Encapsulated in awrgdrpt.sql, awrgdrpi.sql, and awrgdinp.sql
dbms_workload_repository.awr_global_diff_report_html(
dbid1 IN NUMBER,
inst_num1 IN VARCHAR2,
bid1 IN NUMBER,
eid1 IN NUMBER,
dbid2 IN NUMBER,
inst_num2 IN VARCHAR2,
bid2 IN NUMBER,
eid2 IN NUMBER)
RETURN awrrpt_html_type_table PIPELINED;
SELECT dbid FROM v$database;
set feedback off
set heading on
set linesize 1500
set termout on
set trim on
set trimspool on
set veri off
col instart_fmt noprint
col inst_name format a12 heading 'Instance'
col db_name format a12 heading 'DB Name'
col snap_id format 99999990 heading 'Snap Id'
col snapdat format a18 heading 'Snap Started' just c
col lvl format 99 heading 'Snap|Level'
break on inst_name on db_name on host on instart_fmt skip 1
ttitle off
SELECT TO_CHAR(s.startup_time,' DD MON "at" HH24:MI:SS') INSTART_FMT,
di.instance_name INST_NAME, di.db_name DB_NAME, s.snap_id SNAP_ID,
TO_CHAR(s.end_interval_time,'DD MON YYYY HH24:MI') SNAPDAT,
s.snap_level LVL
FROM dba_hist_snapshot s, dba_hist_database_instance di
WHERE di.dbid = s.dbid
AND di.instance_number = s.instance_number
AND di.startup_time = s.startup_time
ORDER BY snap_id;
set trimspool on
set trim on
spool c:\temp\demo.html
Displays the Global AWR Compare Periods Report in text format. The output is one column of VARCHAR2(320)
Overload 1
dbms_workload_repository.awr_global_diff_report_text(
dbid1 IN NUMBER,
inst_num1 IN AWRRPT_INSTANCE_LIST_TYPE,
bid1 IN NUMBER,
eid1 IN NUMBER,
dbid2 IN NUMBER,
inst_num2 IN AWRRPT_INSTANCE_LIST_TYPE,
bid2 IN NUMBER,
eid2 IN NUMBER)
RETURN awrdrpt_text_type_table PIPELINED;
TBD
Overload 2
dbms_workload_repository.awr_global_diff_report_text(
dbid1 IN NUMBER,
inst_num1 IN VARCHAR2,
bid1 IN NUMBER,
eid1 IN NUMBER,
dbid2 IN NUMBER,
inst_num2 IN VARCHAR2,
bid2 IN NUMBER,
eid2 IN NUMBER)
RETURN awrdrpt_text_type_table PIPELINED;
SELECT dbid FROM v$database;
col instart_fmt noprint
col inst_name format a12 heading 'Instance'
col db_name format a12 heading 'DB Name'
col snap_id format 99999990 heading 'Snap Id'
col snapdat format a18 heading 'Snap Started' just c
col lvl format 99 heading 'Snap|Level'
set heading on
break on inst_name on db_name on host on instart_fmt skip 1
ttitle off
SELECT TO_CHAR(s.startup_time,' DD MON "at" HH24:MI:SS') INSTART_FMT,
di.instance_name INST_NAME, di.db_name DB_NAME, s.snap_id SNAP_ID,
TO_CHAR(s.end_interval_time,'DD MON YYYY HH24:MI') SNAPDAT,
s.snap_level LVL
FROM dba_hist_snapshot s, dba_hist_database_instance di
WHERE di.dbid = s.dbid
AND di.instance_number = s.instance_number
AND di.startup_time = s.startup_time
ORDER BY snap_id;
set trimspool on
set trim on
spool c:\temp\demo.txt
dbms_workload_repository.awr_global_report_html(
l_dbid IN NUMBER,
l_inst_num IN AWRRPT_INSTANCE_LIST_TYPE,
l_bid IN NUMBER,
l_eid IN NUMBER,
l_options IN NUMBER DEFAULT 0)
RETURN awrrpt_html_type_table PIPELINED;
TBD
Overload 2
dbms_workload_repository.awr_global_report_html(
l_dbid IN NUMBER,
l_inst_num IN VARCHAR2,
l_bid IN NUMBER,
l_eid IN NUMBER,
l_options IN NUMBER DEFAULT 0)
RETURN awrrpt_html_type_table PIPELINED;
SELECT dbid FROM v$database;
col instart_fmt noprint
col inst_name format a12 heading 'Instance'
col db_name format a12 heading 'DB Name'
col snap_id format 99999990 heading 'Snap Id'
col snapdat format a18 heading 'Snap Started' just c
col lvl format 99 heading 'Snap|Level'
set heading on
break on inst_name on db_name on host on instart_fmt skip 1
ttitle off
SELECT TO_CHAR(s.startup_time,' DD MON "at" HH24:MI:SS') INSTART_FMT,
di.instance_name INST_NAME, di.db_name DB_NAME,
s.snap_id SNAP_ID,
TO_CHAR(s.end_interval_time,'DD MON YYYY HH24:MI') SNAPDAT,
s.snap_level LVL
FROM dba_hist_snapshot s, dba_hist_database_instance di
WHERE di.dbid = s.dbid
AND di.instance_number = s.instance_number
AND di.startup_time = s.startup_time
ORDER BY snap_id;
set trimspool on
set trim on
spool c:\temp\demo.html
SELECT * FROM TABLE(dbms_workload_repository.awr_global_report_html(428676178, '1', 10548, 10550, 0));
dbms_workload_repository.awr_global_report_text(
l_dbid IN NUMBER,
l_inst_num IN AWRRPT_INSTANCE_LIST_TYPE,
l_bid IN NUMBER,
l_eid IN NUMBER,
l_options IN NUMBER DEFAULT 0)
RETURN awrrpt_html_type_table PIPELINED;
TBD
Overload 2
dbms_workload_repository.awr_global_report_text(
l_dbid IN NUMBER,
l_inst_num IN VARCHAR2,
l_bid IN NUMBER,
l_eid IN NUMBER,
l_options IN NUMBER DEFAULT 0)
RETURN awrrpt_html_type_table PIPELINED;
SELECT dbid FROM v$database;
col instart_fmt noprint
col inst_name format a12 heading 'Instance'
col db_name format a12 heading 'DB Name'
col snap_id format 99999990 heading 'Snap Id'
col snapdat format a18 heading 'Snap Started' just c
col lvl format 99 heading 'Snap|Level'
set heading on
break on inst_name on db_name on host on instart_fmt skip 1
ttitle off
SELECT TO_CHAR(s.startup_time,' DD MON "at" HH24:MI:SS') INSTART_FMT,
di.instance_name INST_NAME, di.db_name DB_NAME,
s.snap_id SNAP_ID,
TO_CHAR(s.end_interval_time,'DD MON YYYY HH24:MI') SNAPDAT,
s.snap_level LVL
FROM dba_hist_snapshot s, dba_hist_database_instance di
WHERE di.dbid = s.dbid
AND di.instance_number = s.instance_number
AND di.startup_time = s.startup_time
ORDER BY snap_id;
set trimspool on
set trim on
spool c:\temp\demo.txt
SELECT * FROM TABLE(dbms_workload_repository.awr_global_report_text(2497516142, '1', 65, 70, 0));
dbms_workload_repository.awr_report(
l_dbid IN NUMBER,
l_inst_num IN NUMBER,
l_bid IN NUMBER,
l_eid IN NUMBER,
l_options IN NUMBER DEFAULT 0,
l_format IN VARCHAR2 DEFAULT 'html')
RETURN CLOB;
dbms_workload_repository.awr_report_html(
l_dbid IN NUMBER,
l_inst_num IN NUMBER,
l_bid IN NUMBER,
l_eid IN NUMBER,
l_options IN NUMBER DEFAULT 0)
RETURN awrrpt_text_type_table PIPELINED;
See AWR Report demo linked at the bottom of the page
dbms_workload_repository.awr_report_text(
l_dbid IN NUMBER,
l_inst_num IN NUMBER,
l_bid IN NUMBER,
l_eid IN NUMBER,
l_options IN NUMBER DEFAULT 0)
RETURN awrrpt_text_type_table PIPELINED;
See AWR Report demo linked at the bottom of the page
Allows configuring of specified report thresholds. Allows control of the number of report rows
dbms_workload_repository.awr_set_report_thresholds(
top_n_events IN NUMBER DEFAULT NULL,
top_n_files IN NUMBER DEFAULT NULL,
top_n_segments IN NUMBER DEFAULT NULL,
top_n_services IN NUMBER DEFAULT NULL,
top_n_sql IN NUMBER DEFAULT NULL,
top_n_sql_max IN NUMBER DEFAULT NULL,
top_sql_pct IN NUMBER DEFAULT NULL,
shmem_threshold IN NUMBER DEFAULT NULL,
versions_threshold IN NUMBER DEFAULT NULL,
op_n_disks IN NUMBER DEFAULT NULL,
outlier_pct IN NUMBER DEFAULT NULL,
outlier_cpu_pct IN NUMBER DEFAULT NULL);
dbms_workload_repository.awr_sql_report_html(
l_dbid IN NUMBER,
l_inst_num IN NUMBER,
l_bid IN NUMBER,
l_eid IN NUMBER,
l_sqlid IN VARCHAR2,
l_options IN NUMBER DEFAULT 0)
RETURN awrrpt_html_type_table PIPELINED;
SELECT dbid FROM v$database;
SELECT inst_id
FROM gv$instance;
set pagesize 0
set linesize 121
col instart_fmt noprint
col inst_name format a12 heading 'Instance'
col db_name format a12 heading 'DB Name'
col snap_id format 99999990 heading 'Snap Id'
col snapdat format a18 heading 'Snap Started' just c
col lvl format 99 heading 'Snap|Level'
set heading on
break on inst_name on db_name on host on instart_fmt skip 1
ttitle off
SELECT TO_CHAR(s.startup_time,' DD MON "at" HH24:MI:SS') INSTART_FMT,
di.instance_name INST_NAME, di.db_name DB_NAME, s.snap_id SNAP_ID,
TO_CHAR(s.end_interval_time,'DD MON YYYY HH24:MI') SNAPDAT,
s.snap_level LVL
FROM dba_hist_snapshot s, dba_hist_database_instance di
WHERE di.dbid = s.dbid
AND di.instance_number = s.instance_number
AND di.startup_time = s.startup_time
ORDER BY snap_id;
SELECT sql_id
FROM gv$active_session_history
WHERE TRUNC(sql_exec_start) = TRUNC(SYSDATE);
spool c:\temp\awr_sql_rpt.html
SELECT * FROM TABLE(dbms_workload_repository.awr_sql_report_html(428676178, 1, 1230, 1231, 'a01hp0psv0rrh'));
dbms_workload_repository.awr_sql_report_text(
l_dbid IN NUMBER,
l_inst_num IN NUMBER,
l_bid IN NUMBER,
l_eid IN NUMBER,
l_sqlid IN VARCHAR2,
l_options IN NUMBER DEFAULT 0)
RETURN awrsqrpt_text_type_table PIPELINED;
SELECT dbid FROM v$database;
SELECT inst_id
FROM gv$instance;
set pagesize 0
set linesize 121
col instart_fmt noprint
col inst_name format a12 heading 'Instance'
col db_name format a12 heading 'DB Name'
col snap_id format 99999990 heading 'Snap Id'
col snapdat format a18 heading 'Snap Started' just c
col lvl format 99 heading 'Snap|Level'
set heading on
break on inst_name on db_name on host on instart_fmt skip 1
ttitle off
SELECT TO_CHAR(s.startup_time,' DD MON "at" HH24:MI:SS') INSTART_FMT,
di.instance_name INST_NAME, di.db_name DB_NAME, s.snap_id SNAP_ID,
TO_CHAR(s.end_interval_time,'DD MON YYYY HH24:MI') SNAPDAT,
s.snap_level LVL
FROM dba_hist_snapshot s, dba_hist_database_instance di
WHERE di.dbid = s.dbid
AND di.instance_number = s.instance_number
AND di.startup_time = s.startup_time
ORDER BY snap_id;
SELECT sql_id
FROM gv$active_session_history
WHERE TRUNC(sql_exec_start) = TRUNC(SYSDATE);
spool c:\temp\awr_sql_rpt.txt
SELECT * FROM TABLE(dbms_workload_repository.awr_sql_report_text(428676178, 1, 1230, 1231, 'a01hp0psv0rrh'));
Controls if AWR snapshots are allowed to occur even if the restricted session mode has been enabled for the database. TRUE allows snapshot capture in restricted session mode.
It does so by modifying an undocumented initialization parameter as shown.
dbms_workload_repository.control_restricted_snapshot(allow IN BOOLEAN);
col name format a25
col description format a30
SELECT x.ksppinm NAME, y.ksppstvl VALUE, x.ksppdesc DESCRIPTION
FROM x$ksppi x, x$ksppcv y
WHERE x.inst_id = userenv('Instance')
AND y.inst_id = userenv('Instance')
AND x.indx = y.indx
AND SUBSTR(x.ksppinm,1,1) = '_'
AND lower(x.ksppdesc) like '%awr%restrict%'
ORDER BY 1;
SELECT x.ksppinm NAME, y.ksppstvl VALUE, x.ksppdesc DESCRIPTION
FROM x$ksppi x, x$ksppcv y
WHERE x.inst_id = userenv('Instance')
AND y.inst_id = userenv('Instance')
AND x.indx = y.indx
AND SUBSTR(x.ksppinm,1,1) = '_'
AND lower(x.ksppdesc) like '%awr%restrict%'
ORDER BY 1;
dbms_workload_repository.create_baseline(
start_snap_id IN NUMBER,
end_snap_id IN NUMBER,
baseline_name IN VARCHAR2,
dbid IN NUMBER DEFAULT NULL
expiration IN NUMBER DEFAULT NULL);
SELECT dbid FROM v$database;
SELECT snap_id, startup_time
FROM dba_hist_snapshot
ORDER BY 1,2;
SELECT baseline_name, dbid
FROM dba_hist_baseline;
SELECT baseline_name, dbid
FROM dba_hist_baseline;
Overload 2
dbms_workload_repository.create_baseline(
start_snap_id IN NUMBER,
end_snap_id IN NUMBER,
baseline_name IN VARCHAR2,
dbid IN NUMBER DEFAULT NULL,
expiration IN NUMBER DEFAULT NULL)
RETURN NUMBER;
SELECT dbid FROM v$database;
set linesize 121
col startup_time format a40
SELECT snap_id, startup_time
FROM dba_hist_snapshot
ORDER BY 1,2;
SELECT baseline_name, dbid
FROM dba_hist_baseline;
set serveroutput on
DECLARE
i dba_hist_baseline.baseline_id%TYPE;
BEGIN
i := dbms_workload_repository.create_baseline(1199, 1207, 'UW_BASE', 428676178);
dbms_output.put_line(TO_CHAR(i));
END;
/
SELECT baseline_id, baseline_name
FROM dba_hist_baseline;
Overload 3
dbms_workload_repository.create_baseline(
start_time IN DATE,
end_time IN DATE,
baseline_name IN VARCHAR2,
dbid IN NUMBER DEFAULT NULL,
expiration IN NUMBER DEFAULT NULL);
dbms_workload_repository.create_baseline(
start_time IN DATE,
end_time IN DATE,
baseline_name IN VARCHAR2,
dbid IN NUMBER DEFAULT NULL,
expiration IN NUMBER DEFAULT NULL)
RETURN NUMBER;
DECLARE
i dba_hist_baseline.baseline_id%TYPE;
BEGIN
i := dbms_workload_repository.create_baseline(SYSDATE-2/24, SYSDATE-1/24, 'UW_BASE', 428676178);
dbms_output.put_line(TO_CHAR(i));
END;
/
Creates a Baseline Template for a single time period. There will be a MMON task that will use these inputs to create a Baseline for the time period when the time comes.
Overload 1
dbms_workload_repository.create_baseline_template(
start_time IN DATE,
end_time IN DATE,
baseline_name IN VARCHAR2,
template_name IN VARCHAR2,
expiration IN NUMBER DEFAULT NULL,
dbid IN NUMBER DEFAULT NULL);
desc dba_hist_baseline_template
SELECT dbid, template_id, template_name, template_type
FROM dba_hist_baseline_template;
SELECT baseline_name, dbid
FROM dba_hist_baseline;
SELECT dbid, template_id, template_name, template_type
FROM dba_hist_baseline_template;
Overload 2
dbms_workload_repository.create_baseline_template(
day_of_week IN VARCHAR2,
hour_in_day IN NUMBER,
duration IN NUMBER,
start_time IN DATE,
end_time IN DATE,
baseline_name_prefix IN VARCHAR2,
template_name IN VARCHAR2,
expiration IN NUMBER DEFAULT 35,
dbid IN NUMBER DEFAULT NULL);
Create a manual AWR snapshot from a remote database
Overload 1
dbms_workload_repository.create_remote_snapshot(
node_id IN NUMBER,
flush_level IN VARCHAR2 DEFAULT 'BESTFIT');
TBD
Overload 2
dbms_workload_repository.create_remote_snapshot(
node_id IN NUMBER,
flush_level IN VARCHAR2 DEFAULT 'BESTFIT')
RETURN NUMBER;
TBD
Overload 3
dbms_workload_repository.create_remote_snapshot(
node_name IN VARCHAR2,
topology_name IN VARCHAR2 DEFAULT NULL,
flush_level IN VARCHAR2 DEFAULT 'BESTFIT');
TBD
Overload 4
dbms_workload_repository.create_remote_snapshot(
node_name IN VARCHAR2,
topology_name IN VARCHAR2 DEFAULT NULL,
flush_level IN VARCHAR2 DEFAULT 'BESTFIT')
RETURN NUMBER;
Extracts AWR data from the AWR schema and writes it to a file
dbms_workload_repository.extract(
schname IN VARCHAR2,
dmpfile IN VARCHAR2 DEFAULT 'awrdat',
dmpdir IN VARCHAR2 DEFAULT 'DATA_PUMP_DIR',
new_dbid IN NUMBER DEFAULT NULL,
dup_snapshot_ok IN BOOLEAN DEFAULT TRUE,
gather_stats IN BOOLEAN DEFAULT FALSE,
source_name IN VARCHAR2 DEFAULT NULL,
logfile IN VARCHAR2
DEFAULT NULL,
logdir IN VARCHAR2 DEFAULT NULL);
exec dbms_workload_repository.extract('XDB');
-- this may take a number of minutes to complete
-- monitor the dmpdir to monitor the progress
-- it can also generate a file of substantial size
-- as well as a valuable log file listing what was extracted
Returns an appropriate AWR view name, given a DBA_HIST view name and AWR location
dbms_workload_repository.get_awr_view_name_by_location(
dba_hist_view_name IN VARCHAR2, -- DBA_HIST view name
awr_location IN VARCHAR2) -- AWR_ROOT or AWR_PDB
RETURN VARCHAR2;
SELECT view_name
FROM dba_views
WHERE view_name LIKE 'DBA_HIST%'
ORDER BY 1;
Imports AWR data from a previous EXTRACT file (see above) into the SYS schema
dbms_workload_repository.load(
schname IN VARCHAR2,
dmpfile IN VARCHAR2 DEFAULT 'awrdat',
dmpdir IN VARCHAR2 DEFAULT 'DATA_PUMP_DIR',
new_dbid IN NUMBER DEFAULT NULL,
dup_snapshot_ok IN BOOLEAN DEFAULT TRUE,
gather_stats IN BOOLEAN DEFAULT FALSE,
source_name IN VARCHAR2 DEFAULT NULL,
logfile IN VARCHAR2 DEFAULT NULL,
logdir IN VARCHAR2 DEFAULT NULL);
Modifies the interval between snapshots and/or the retention of snapshots in the repository
Overload 1
Note: Some of this functionality also exists in DBMS_MANAGEMENT_PACKS
MODIFY_AWR_SETTINGS proc
dbms_workload_repository.modify_snapshot_settings(
retention IN NUMBER DEFAULT NULL,
interval IN NUMBER DEFAULT NULL,
topnsql IN NUMBER DEFAULT NULL,
dbid IN NUMBER DEFAULT NULL);
Defaults
RETENTION
8 days = 10080 minutes
INTERVAL
60 minutes *
*
Recommend this be reset to 15-20 min. maximum between snapshots
set linesize 121
col retention format a20
col snap_interval format a20
SELECT retention, snap_interval, topnsql
FROM wrm$_wr_control
WHERE dbid = (SELECT dbid FROM v$database);
SELECT retention, snap_interval, topnsql
FROM wrm$_wr_control
WHERE dbid = (SELECT dbid FROM v$database);
Overload 2
dbms_workload_repository.modify_snapshot_settings(
retention IN NUMBER DEFAULT NULL,
interval IN NUMBER DEFAULT NULL,
topnsql IN VARCHAR2,
dbid IN NUMBER DEFAULT NULL);
Defaults
RETENTION
7 days = 10080 minutes
INTERVAL
60 minutes *
* Recommend this be reset to 15-30 min. maximum between snapshots
TOPNSQL
Users are allowed to specify the following values: ('DEFAULT', 'MAXIMUM', 'N')
Specifying 'DEFAULT' will revert the system back to the default behavior of Top 30 for level TYPICAL and Top 100 for level ALL.
Specifying 'MAXIMUM' will cause the system to capture the complete set of SQL in the cursor cache. Specifying the number 'N' is equivalent to setting the Top N SQL with the NUMBER type.
Specifying 'N' will cause the system to flush the Top N SQL for each criteria. The 'N' string is converted into the number for Top N SQL.
set linesize 121
col retention format a20
col snap_interval format a20
SELECT retention, snap_interval, topnsql
FROM wrm$_wr_control;
dbms_workload_repository.modify_table_settings(
table_name IN VARCHAR2,
dbid IN NUMBER DEFAULT NULL,
flush_level IN VARCHAR2 DEFAULT NULL); -- 'DEAFULT', 'TYPICAL' or 'ALL'
Register a remote database with AWR. The remote database must already be registered with UMF. The input node_id must be the UMF-assigned Node Id for the remote node.
Overload 1
dbms_workload_repository.register_remote_database(node_id IN NUMBER);
TBD
Register a remote database with AWR, using the node_name for identity
Overload 2
dbms_workload_repository.register_remote_database(
node_name IN VARCHAR2,
topology_name IN VARCHAR2 DEFAULT NULL);
Routine to remove a colored SQL ID. If an SQL ID is colored, it will always be captured in every snapshot, independent of its level of activities (i.e. does not have to be a TOP SQL)
dbms_workload_repository.remove_colored_sql(
sql_id IN VARCHAR2,
dbid IN NUMBER DEFAULT NULL);
dbms_workload_repository.select_baseline_metrics(
l_baseline_id IN NUMBER,
l_beg_snap IN NUMBER DEFAULT NULL,
l_end_snap IN NUMBER DEFAULT NULL,
l_dbid IN NUMBER DEFAULT NULL)
RETURN awrbl_details_type_table PIPELINED;
SELECT dbid, baseline_id, baseline_name, baseline_type
FROM dba_hist_baseline;
set linesize 121
col start_snap_time format a30
col end_snap_time format a30
SELECT *
FROM TABLE(dbms_workload_repository.select_baseline_details(0));
dbms_workload_repository.select_baseline_metric(
l_baseline_name IN VARCHAR2,
l_dbid IN NUMBER DEFAULT NULL,
l_instance_num IN NUMBER DEFAULT NULL)
RETURN awrbl_metric_type_table PIPELINED;
SELECT dbid, baseline_id, baseline_name, baseline_type
FROM dba_hist_baseline;
set pagesize 0
set linesize 121
SELECT *
FROM TABLE(dbms_workload_repository.select_baseline_metric(0));
Unregisters a remote database from the AWR. The input node ID must be the UMF Node ID of the remote node
Overload 1
dbms_workload_repository.unregister_remote_database(
node_id IN NUMBER,
remote_check IN BOOLEAN DEFAULT TRUE);
TBD
Overload 2
dbms_workload_repository.unregister_remote_database(
node_name IN VARCHAR2,
topology_name IN VARCHAR2 DEFAULT NULL,
remote_check IN BOOLEAN DEFAULT TRUE);