ITPub博客

首页 > 数据库 > Oracle > 20160111-log switch 统计SQL

20160111-log switch 统计SQL

原创 Oracle 作者:tolilong 时间:2016-01-11 13:08:55 0 删除 编辑

日志切换统计SQL,参考论坛网友,

select trunc(first_time) "Date",to_char(first_time,'Dy') "day",count(1) "Total",
sum(decode(to_char(first_time,'HH24'),'00',1,0)) H0,
sum(decode(to_char(first_time,'HH24'),'01',1,0)) H1,
sum(decode(to_char(first_time,'HH24'),'02',1,0)) H2,
sum(decode(to_char(first_time,'HH24'),'03',1,0)) H3,
sum(decode(to_char(first_time,'HH24'),'04',1,0)) H4,
sum(decode(to_char(first_time,'HH24'),'05',1,0)) H5,
sum(decode(to_char(first_time,'HH24'),'06',1,0)) H6,
sum(decode(to_char(first_time,'HH24'),'07',1,0)) H7,
sum(decode(to_char(first_time,'HH24'),'08',1,0)) H8,
sum(decode(to_char(first_time,'HH24'),'09',1,0)) H9,
sum(decode(to_char(first_time,'HH24'),'10',1,0)) H10,
sum(decode(to_char(first_time,'HH24'),'11',1,0)) H11,
sum(decode(to_char(first_time,'HH24'),'12',1,0)) H12,
sum(decode(to_char(first_time,'HH24'),'13',1,0)) H13,
sum(decode(to_char(first_time,'HH24'),'14',1,0)) H14,
sum(decode(to_char(first_time,'HH24'),'15',1,0)) H15,
sum(decode(to_char(first_time,'HH24'),'16',1,0)) H16,
sum(decode(to_char(first_time,'HH24'),'17',1,0)) H17,
sum(decode(to_char(first_time,'HH24'),'18',1,0)) H18,
sum(decode(to_char(first_time,'HH24'),'19',1,0)) H19,
sum(decode(to_char(first_time,'HH24'),'20',1,0)) H20,
sum(decode(to_char(first_time,'HH24'),'21',1,0)) H21,
sum(decode(to_char(first_time,'HH24'),'22',1,0)) H22,
sum(decode(to_char(first_time,'HH24'),'23',1,0)) H23,round(count(1)/24,2) "Avg"
from gv$log_history
where first_time>sysdate-10 group by trunc(first_time),to_char(first_time,'Dy')
order by 1 desc;

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/24237320/viewspace-1974800/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2010-07-13

  • 博文量
    406
  • 访问量
    1009048