5.     删除基线

如果要删除一个基准线:

SQL> exec dbms_workload_repository.drop_baseline(baseline_name=>'apply_interest_1',cascade=>false);

 

PL/SQL 过程已成功完成。

 

SQL> select *from wrh$_active_session_history where snap_id in (95,96,97,98);

 

   SNAP_ID       DBID INSTANCE_NUMBER  SAMPLE_ID SAMPLE_TIME

---------- ---------- --------------- ---------- -------------------------------

        95 1160732652               1     235360 06-10-07 10.56.29.872 上午

        95 1160732652               1     235230 06-10-07 10.54.19.857 上午

        95 1160732652               1     233130 06-10-07 10.19.19.478 上午

        95 1160732652               1     232830 06-10-07 10.14.18.859 上午

        95 1160732652               1     232250 06-10-07 10.04.38.481 上午

        97 1160732652               1     238600 06-10-07 12.33.08.420 下午

        97 1160732652               1     238600 06-10-07 12.33.08.420 下午

        97 1160732652               1     238600 06-10-07 12.33.08.420 下午

        97 1160732652               1     238600 06-10-07 12.33.08.420 下午

        97 1160732652               1     238600 06-10-07 12.33.08.420 下午

        97 1160732652               1     238600 06-10-07 12.33.08.420 下午

 

   SNAP_ID       DBID INSTANCE_NUMBER  SAMPLE_ID SAMPLE_TIME

---------- ---------- --------------- ---------- -------------------------------

        97 1160732652               1     238420 06-10-07 11.50.55.686 上午

        97 1160732652               1     238230 06-10-07 11.47.45.687 上午

        98 1160732652               1     239140 06-10-07 01.42.00.976 下午

        98 1160732652               1     239140 06-10-07 01.42.00.976 下午

        98 1160732652               1     239140 06-10-07 01.42.00.976 下午

        98 1160732652               1     239140 06-10-07 01.42.00.976 下午

        98 1160732652               1     239140 06-10-07 01.42.00.976 下午

        98 1160732652               1     239130 06-10-07 01.27.04.161 下午

        98 1160732652               1     239130 06-10-07 01.27.04.161 下午

        98 1160732652               1     239130 06-10-07 01.27.04.161 下午

 

已选择21行。

 

SQL> exec dbms_workload_repository.drop_baseline(baseline_name=>'apply_interest_2', cascade=>true);

 

PL/SQL 过程已成功完成。

 

SQL> select *from wrh$_active_session_history where snap_id in (92,93,94);

未选定行

 

SQL>

 

6.     生成报表

awr有个报表生成机制,可以对存储在workload资料库的统计产生汇总报表。这个分析对一段时间的统计做的。这个报表生成机制很像statspack

可以使用脚本awrrpt.sqlawrrpti.sql来查看AWR报告(非常类似statspack中的spreport.sql),这两个脚本都在目录$ORACLE_HOME/rdbms/admin中。Awrrpt.sql脚本可以显示指定快照id范围的诊断信息,报告可以保存为文本文件或HTML文件;awrrpti.sql脚本与awrrpt.sql类似,唯一的不同就是在awrrpti.sql脚本中,你可以指定数据库ID和实例ID(作为参数)。报告包括如下诊断信息:

[1] Report summary
[1] Wait events statistics
[1] SQL statistics
[1] Instance activity statistics
[1] I/O statistics
[1] Buffer pool statistics
[1] Advisory statistics
[1] Wait statistics
[1] Undo statistics
[1] Latch statistics
 Segment statistics
[1] Dictionary cache statistics
[1] Library cache statistics
[1] SGA statistics
[1] Resource limit statistics
[1] init.ora parameters

通过运行$ORACLE_HOME/rdbms/admin目录中的awrrpt.sql脚本,AWR的功能可以立即通过它从采集的统计数据和量度中生成的报表得到最好的说明。这个脚本显示所有的现有AWR快照并请求两个特定的快照作为时间间隔边界。它产生两种类型的输出:文本格式(类似于Statspack报表的文本格式但来自于AWR信息库)和默认的HTML格式(拥有到部分和子部分的所有超链接),从而提供了非常用户友好的报表。

运行这个脚本必须要select any dictionary权限.这个脚本提示你输入选项如怎么和在哪里生成这个报表:

*首先,你需要指明你要生成html还是text格式的
*
要选择快照的天数:输入天数,和你最近的快照,可选的,你可以使用dba_hist_snapshot表来看你要用哪个snap_id.
*
开始snap_id和终止snap_id,这个快照对定义你的报表产生的时间间隔.
*
文件名称,报告写的用户指定的文件.

现在运行该脚本以查看报表,从而对AWR的报表功能有一个直观的了解。

SQL> @D:/oracle/product/10.2.0/db_1/RDBMS/ADMIN/awrrpt.sql

 

Current Instance

~~~~~~~~~~~~~~~~

 

   DB Id    DB Name      Inst Num Instance

----------- ------------ -------- ------------

 1160732652 ORCL                1 orcl

 

 

Specify the Report Type

~~~~~~~~~~~~~~~~~~~~~~~

Would you like an HTML report, or a plain text report?

Enter 'html' for an HTML report, or 'text' for plain text

Defaults to 'html'

输入 report_type 的值:

 

Type Specified:                  html

 

 

Instances in this Workload Repository schema

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

   DB Id     Inst Num DB Name      Instance     Host

------------ -------- ------------ ------------ ------------

* 1160732652        1 ORCL         orcl         YUECHAOTIAN

 

Using 1160732652 for database Id

Using          1 for instance number

 

 

Specify the number of days of snapshots to choose from

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Entering the number of days (n) will result in the most recent

(n) days of snapshots being listed.  Pressing <return> without

specifying a number lists all completed snapshots.

 

 

输入 num_days 的值:  4

 

Listing the last 4 days of Completed Snapshots

 

                                                        Snap

Instance     DB Name        Snap Id    Snap Started    Level

------------ ------------ --------- ------------------ -----

orcl         ORCL                81 04 10 2007 07:24     1

 

                                 83 05 10 2007 13:34     1

                                 84 05 10 2007 16:19     1

                                 85 05 10 2007 17:00     1

                                 86 05 10 2007 18:00     1

                                 87 05 10 2007 19:10     1

                                 88 05 10 2007 20:00     1

                                 89 05 10 2007 21:00     1

                                 90 05 10 2007 22:00     1

                                 91 05 10 2007 23:00     1

 

                                 95 06 10 2007 11:00     1

                                 97 06 10 2007 13:27     1

                                 98 06 10 2007 13:44     1

                                 99 06 10 2007 14:00     1

                                100 06 10 2007 14:30     1

                                101 06 10 2007 15:00     1

                                102 06 10 2007 15:30     1

 

 

 

Specify the Begin and End Snapshot Ids

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

输入 begin_snap 的值:  100

Begin Snapshot Id specified: 100

 

输入 end_snap 的值:  102

End   Snapshot Id specified: 102

 

 

 

Specify the Report Name

~~~~~~~~~~~~~~~~~~~~~~~

The default report file name is awrrpt_1_100_102.html.  To use this name,

press <return> to continue, otherwise enter an alternative.

 

输入 report_name 的值:

 

Using the report name awrrpt_1_100_102.html

 

<HTML><HEAD><TITLE>AWR Report</TITLE>

……(省略结果)

End of Report

</BODY></HTML>

Report written to awrrpt_1_100_102.html

SQL>