awrrpt.sql は、awrrpti をコールしているだけ。
この時、いくつか bind 変数を設定している。
--
-- Get the current database/instance information - this will be used
-- later in the report along with bid, eid to lookup snapshots
set echo off heading on underline on;
column inst_num heading "Inst Num" new_value inst_num format 99999;
column inst_name heading "Instance" new_value inst_name format a12;
column db_name heading "DB Name" new_value db_name format a12;
column dbid heading "DB Id" new_value dbid format 9999999999 just c;
prompt
prompt Current Instance
prompt ~~~~~~~~~~~~~~~~
select d.dbid dbid
, d.name db_name
, i.instance_number inst_num
, i.instance_name inst_name
from v$database d,
v$instance i;
@@awrrpti
awrrpti.sql をみると、こんなコメントが。
Rem NAME
Rem awrrpti.sql - Workload Repository Report Instance
Rem
Rem DESCRIPTION
Rem SQL*Plus command file to report on differences between
Rem values recorded in two snapshots.
Rem
Rem This script requests the user for the dbid and instance number
Rem of the instance to report on, before producing the standard
Rem Workload Repository report.
Rem
Rem NOTES
Rem Run as SYSDBA. Generally this script should be invoked by awrrpt,
Rem unless you want to pick a database other than the default.
Rem
Rem If you want to use this script in an non-interactive fashion,
Rem without executing the script through awrrpt, then
Rem do something similar to the following:
Rem
Rem define inst_num = 1;
Rem define num_days = 3;
Rem define inst_name = 'Instance';
Rem define db_name = 'Database';
Rem define dbid = 4;
Rem define begin_snap = 10;
Rem define end_snap = 11;
Rem define report_type = 'text';
Rem define report_name = /tmp/swrf_report_10_11.txt
Rem @@?/rdbms/admin/awrrpti
non-interactive で実行するための手順が書いてある。
いくつかの bind変数を指定して、awrrpti.sql を実行すればいいとのこと。
ちなみに、db_name と inst_name は、指定しなくても動く。
db_name と inst_nameだけ指定して dbid と inst_num を指定しなくても動いてくれるかなぁ・・・。
と期待したらダメだった。
まあ、同じ db_name の AWR を単一の環境に入れることもできるからな・・・。
db_name じゃだめか。