mystat.sql & mystat2.sql

木頭一個發表於2008-06-09

mystat.sql和mystat2.sql可以根據v$mystat檢視中的資訊得出執行各個語句的各項統計值

--mystat.sql
set echo off
set verify off
column value new_val V
define S="&1"
 

set autotrace off
select a.name,b.value from v$statname a,v$mystat b
where a.statistic#=b.statistic#
and lower(a.name) like '%'||lower('&S')||'%'
/
set echo on;


--mystat2.sql
set echo off
set verify off

select a.name,b.value V,to_char(b.value-&V,'999,999,999,999') diff
from v$statname a,v$mystat b
where a.statistic#=b.statistic#
and lower(a.name) like '%'||lower('&S')||'%'
/

set echo on

執行方法(比如檢視一條delete語句生成的redo):
sys@T>@M:\Database\Scripts\mystat "redo size"
sys@T>set echo off

NAME                                                                  VALUE
---------------------------------------------------------------- ----------
redo size                                                                 0

sys@T>delete dual;

1 row deleted.

sys@T>@M:\Database\Scripts\mystat2
sys@T>set echo off

NAME                                                                      V DIFF
---------------------------------------------------------------- ---------- ----------------
redo size                                                               672              672

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/498744/viewspace-343178/,如需轉載,請註明出處,否則將追究法律責任。