要使用runstats,需要能访问几个神奇的动态性能表:V$STATNAME、V$MYSTAT 和 V$LATCH。
例如:创建视图
create or replace view stats
as select 'STAT...'||a.name name,b.value
from v$statname a,v$mystat b
where a.statistic#=b.statistic#
union all
select 'LATCH.'||name,gets
from v$latch;
但是普通用户需要获得授权才可以使用,通过sqlplus用管理员身份连接到数据库给普通用户授权:
grant select on V_$STATNAME to SCOTT;
grant select on V_$MYSTAT to SCOTT;
grant select on V_$LATCH to SCOTT;