本文共 4342 字,大约阅读时间需要 14 分钟。
我们知道,Oracle提供的脚本均位于下列目录下
$ORACLE_HOME/rdbms/admin
其中,
awrsqrpt.sql用来分析某条指定的SQL语句,通过awrsqrpt.sql脚本,awr能够生成指定曾经执行过的SQL的执行计划,当时消耗的资源等情况。
常用的几个如下:
artisandb:[/oracle$]sqlplus /nologSQL*Plus: Release 11.2.0.4.0 Production on Sun Jun 17 17:51:56 2018Copyright (c) 1982, 2013, Oracle. All rights reserved.SQL> connect artisan/artisan2017@PR_CCConnected.SQL> @$ORACLE_HOME/rdbms/admin/awrsqrpt.sqlCurrent Instance~~~~~~~~~~~~~~~~ DB Id DB Name Inst Num Instance----------- ------------ -------- ------------ 2143881171 ARTISAN 1 artisanSpecify the Report Type~~~~~~~~~~~~~~~~~~~~~~~Would you like an HTML report, or a plain text report?Enter 'html' for an HTML report, or 'text' for plain textDefaults to 'html'Enter value for report_type: ------ 输入report类型,不输入使用默认html格式Type Specified: htmlInstances in this Workload Repository schema~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DB Id Inst Num DB Name Instance Host------------ -------- ------------ ------------ ------------* 2143881171 1 ARTISAN artisan artisandbUsing 2143881171 for database IdUsing 1 for instance numberSpecify 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. Pressingwithoutspecifying a number lists all completed snapshots.Enter value for num_days: 1 ------ 输入列出快照近几天的数据Listing the last day's Completed Snapshots SnapInstance 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 1Specify the Begin and End Snapshot Ids~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Enter value for begin_snap: 11989 ------ 输入开始的snapIdBegin Snapshot Id specified: 11989Enter value for end_snap: 11994 ------ 输入结束的snapIdEnd Snapshot Id specified: 11994Specify the SQL Id~~~~~~~~~~~~~~~~~~Enter value for sql_id: 3r0ccnd9v7q40 ------ 输入特定的sqlIdSQL ID specified: 3r0ccnd9v7q40Specify the Report Name~~~~~~~~~~~~~~~~~~~~~~~The default report file name is awrsqlrpt_1_11989_11994.html. To use this name,press 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_HOME/rdbms/admin/awrsqrpi.sql