o4-tom's mystat.sql & mystat2.sql

时间:2022-09-05 20:04:29

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