如何產生指定SQL語句的AWR報表

來源:互聯網
上載者:User

1,產生指定SQL語句的統計報表
  如果希望對多執行個體的資料庫做對比,那就要使用$Oracle_HOME/rdbms/admin/awrddrpi.sql指令碼了。該指令碼的操作基本與單一實例基本相同,這裡不再示範,感興趣的朋友可以自己測試下。

2 ,產生指定SQL語句的統計報表
  這項統計專門用來分析某條指定的SQL語句,通過awrsqrpt.sql指令碼,awr能夠產生指定sql(曾經執行過的SQL)的執行計畫,消耗的資源等等資訊,有助於DBA進行SQL調優。
[oracle@even ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Sun Dec 23 11:39:53 2012

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining options

SQL> exec dbms_workload_repository.create_snapshot;

PL/SQL procedure successfully completed.

SQL> @$ORACLE_HOME/rdbms/admin/awrsqrpt.sql

Current Instance
~~~~~~~~~~~~~~~~

  DB Id    DB Name      Inst Num Instance
----------- ------------ -------- ------------
 2100083002 TEST                1 test


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'
Enter value for report_type: html

Type Specified:  html


Instances in this Workload Repository schema
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  DB Id    Inst Num DB Name      Instance    Host
------------ -------- ------------ ------------ ------------
* 2100083002        1 TEST        test        even.oracle.
                                                com

Using 2100083002 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.


Enter value for num_days: 1

Listing the last day's Completed Snapshots

                                                        Snap
Instance    DB Name        Snap Id    Snap Started    Level
------------ ------------ --------- ------------------ -----
test        TEST                34 23 Dec 2012 11:00      1
                                35 23 Dec 2012 11:30      1
                                36 23 Dec 2012 11:40      1

 

Specify the Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter value for begin_snap: 34
Begin Snapshot Id specified: 34

Enter value for end_snap: 36
End  Snapshot Id specified: 36

 


Specify the SQL Id
~~~~~~~~~~~~~~~~~~
  注意,這裡要指定分析的SQL_ID,你可能想問,要分析的SQL ID從何而來呢?一般來說,SQL_ID可以通過V$SQL(及其它相關視圖),要麼是通過AWR/STATSPACK等工具。
Enter value for sql_id: 4vsh055snc3du
SQL ID specified:  4vsh055snc3du

Specify the Report Name
~~~~~~~~~~~~~~~~~~~~~~~
The default report file name is awrsqlrpt_1_34_36.html.  To use this name,
press <return> to continue, otherwise enter an alternative.

Enter value for report_name: /home/oracle/awr_20121231.html

Using the report name /home/oracle/awr_20121231.html


<HTML><HEAD><TITLE>AWR SQL Report</TITLE><style type="text/css">body.awr {font:bold 10pt Arial,Helvetica,Geneva,sans-serif;color:black;
......
......
.....
</BODY></HTML>
Report written to /home/oracle/awr_20121231.html

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.