天天看點

Oracle-Oracle SQL Report (awrsqrpt.sql/awrsqrpi.sql)生成指定SQL的統計報表概述調用背景腳本awrsqrpt.sql擷取下載下傳檢視叢集中指定特定執行個體的SQL語句的SQL Report

概述

我們知道,Oracle提供的腳本均位于下列目錄下

$ORACLE_HOME/rdbms/admin           

複制

其中,

awrsqrpt.sql用來分析某條指定的SQL語句,通過awrsqrpt.sql腳本,awr能夠生成指定曾經執行過的SQL的執行計劃,當時消耗的資源等情況。

常用的幾個如下:

  • awrrpt.sql :生成指定快照區間的統計報表
  • awrrpti.sql :生成指定資料庫執行個體,并且指定快照區間的統計報表
  • awrsqlrpt.sql :生成指定快照區間,指定SQL語句(實際指定的是該語句的SQLID)的統計報表
  • awrsqrpi.sql :生成指定資料庫執行個體,指定快照區間的指定SQL語句的統計報表
  • awrddrpt.sql :指定兩個不同的時間周期,生成這兩個周期的統計對比報表
  • awrddrpi.sql :指定資料庫執行個體,并指定兩個的不同時間周期,生成這兩個周期的統計對比報表
  • addmrpt.sql:資料庫自動診斷監視工具(Automatic Database Diagnostic Monitor :ADDM)
  • addmrpti.sql:指定資料庫執行個體,資料庫自動診斷監視工具(Automatic Database Diagnostic Monitor :ADDM)

調用背景腳本awrsqrpt.sql擷取

artisandb:[/oracle$]sqlplus /nolog

SQL*Plus: Release 11.2.0.4.0 Production on Sun Jun 17 17:51:56 2018

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

SQL> connect artisan/artisan2017@PR_CC
Connected.
SQL> @$ORACLE_HOME/rdbms/admin/awrsqrpt.sql

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

   DB Id    DB Name      Inst Num Instance
----------- ------------ -------- ------------
 2143881171 ARTISAN                  1 artisan


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:  ------ 輸入report類型,不輸入使用預設html格式

Type Specified:  html


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

   DB Id     Inst Num DB Name      Instance     Host
------------ -------- ------------ ------------ ------------
* 2143881171        1 ARTISAN           artisan           artisandb

Using 2143881171 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
------------ ------------ --------- ------------------ -----
artisan           ARTISAN               11977 17 Jun 2018 00:00      1
                              11978 17 Jun 2018 01:00      1
                              11979 17 Jun 2018 02:00      1
                              11980 17 Jun 2018 03:00      1
                              11981 17 Jun 2018 04:00      1
                              11982 17 Jun 2018 05:00      1
                              11983 17 Jun 2018 06:00      1
                              11984 17 Jun 2018 07:00      1
                              11985 17 Jun 2018 08:00      1
                              11986 17 Jun 2018 09:00      1
                              11987 17 Jun 2018 10:00      1
                              11988 17 Jun 2018 11:00      1
                              11989 17 Jun 2018 12:00      1
                              11990 17 Jun 2018 13:00      1
                              11991 17 Jun 2018 14:00      1
                              11992 17 Jun 2018 15:01      1
                              11993 17 Jun 2018 16:00      1
                              11994 17 Jun 2018 17:00      1



Specify the Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter value for begin_snap: 11989   ------ 輸入開始的snapId
Begin Snapshot Id specified: 11989

Enter value for end_snap: 11994   ------ 輸入結束的snapId
End   Snapshot Id specified: 11994




Specify the SQL Id
~~~~~~~~~~~~~~~~~~
Enter value for sql_id: 3r0ccnd9v7q40  ------ 輸入特定的sqlId
SQL ID specified:  3r0ccnd9v7q40

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

Enter value for report_name:  ------ 輸入報告名稱,不輸入使用預設名稱

Using the report name awrsqlrpt_1_11989_11994.html

........
........
........
Report written to awrsqlrpt_1_11989_11994.html           

複制

下載下傳檢視

Oracle-Oracle SQL Report (awrsqrpt.sql/awrsqrpi.sql)生成指定SQL的統計報表概述調用背景腳本awrsqrpt.sql擷取下載下傳檢視叢集中指定特定執行個體的SQL語句的SQL Report

叢集中指定特定執行個體的SQL語句的SQL Report

針對多執行個體資料庫,使用

@$ORACLE_HOME/rdbms/admin/awrsqrpi.sql           

複制