DBA日常SQL之查询数据库运行状况

SELECT SUBSTR(TO_CHAR(first_time, ‘MM/DD/RR HH:MI:SS‘),1,5) Day,
       SUM(DECODE(SUBSTR(TO_CHAR(first_time, ‘MM/DD/RR HH24:MI:SS‘),10,2),‘00‘,1,0)) H00,
       SUM(DECODE(SUBSTR(TO_CHAR(first_time, ‘MM/DD/RR HH24:MI:SS‘),10,2),‘01‘,1,0)) H01,
       SUM(DECODE(SUBSTR(TO_CHAR(first_time, ‘MM/DD/RR HH24:MI:SS‘),10,2),‘02‘,1,0)) H02,
       SUM(DECODE(SUBSTR(TO_CHAR(first_time, ‘MM/DD/RR HH24:MI:SS‘),10,2),‘03‘,1,0)) H03,
       SUM(DECODE(SUBSTR(TO_CHAR(first_time, ‘MM/DD/RR HH24:MI:SS‘),10,2),‘04‘,1,0)) H04,
       SUM(DECODE(SUBSTR(TO_CHAR(first_time, ‘MM/DD/RR HH24:MI:SS‘),10,2),‘05‘,1,0)) H05,
       SUM(DECODE(SUBSTR(TO_CHAR(first_time, ‘MM/DD/RR HH24:MI:SS‘),10,2),‘06‘,1,0)) H06,
       SUM(DECODE(SUBSTR(TO_CHAR(first_time, ‘MM/DD/RR HH24:MI:SS‘),10,2),‘07‘,1,0)) H07,
       SUM(DECODE(SUBSTR(TO_CHAR(first_time, ‘MM/DD/RR HH24:MI:SS‘),10,2),‘08‘,1,0)) H08,
       SUM(DECODE(SUBSTR(TO_CHAR(first_time, ‘MM/DD/RR HH24:MI:SS‘),10,2),‘09‘,1,0)) H09,
       SUM(DECODE(SUBSTR(TO_CHAR(first_time, ‘MM/DD/RR HH24:MI:SS‘),10,2),‘10‘,1,0)) H10,
       SUM(DECODE(SUBSTR(TO_CHAR(first_time, ‘MM/DD/RR HH24:MI:SS‘),10,2),‘11‘,1,0)) H11,
       SUM(DECODE(SUBSTR(TO_CHAR(first_time, ‘MM/DD/RR HH24:MI:SS‘),10,2),‘12‘,1,0)) H12,
       SUM(DECODE(SUBSTR(TO_CHAR(first_time, ‘MM/DD/RR HH24:MI:SS‘),10,2),‘13‘,1,0)) H13,
       SUM(DECODE(SUBSTR(TO_CHAR(first_time, ‘MM/DD/RR HH24:MI:SS‘),10,2),‘14‘,1,0)) H14,
       SUM(DECODE(SUBSTR(TO_CHAR(first_time, ‘MM/DD/RR HH24:MI:SS‘),10,2),‘15‘,1,0)) H15,
       SUM(DECODE(SUBSTR(TO_CHAR(first_time, ‘MM/DD/RR HH24:MI:SS‘),10,2),‘16‘,1,0)) H16,
       SUM(DECODE(SUBSTR(TO_CHAR(first_time, ‘MM/DD/RR HH24:MI:SS‘),10,2),‘17‘,1,0)) H17,
       SUM(DECODE(SUBSTR(TO_CHAR(first_time, ‘MM/DD/RR HH24:MI:SS‘),10,2),‘18‘,1,0)) H18,
       SUM(DECODE(SUBSTR(TO_CHAR(first_time, ‘MM/DD/RR HH24:MI:SS‘),10,2),‘19‘,1,0)) H19,
       SUM(DECODE(SUBSTR(TO_CHAR(first_time, ‘MM/DD/RR HH24:MI:SS‘),10,2),‘20‘,1,0)) H20,
       SUM(DECODE(SUBSTR(TO_CHAR(first_time, ‘MM/DD/RR HH24:MI:SS‘),10,2),‘21‘,1,0)) H21,
       SUM(DECODE(SUBSTR(TO_CHAR(first_time, ‘MM/DD/RR HH24:MI:SS‘),10,2),‘22‘,1,0)) H22 ,
       SUM(DECODE(SUBSTR(TO_CHAR(first_time, ‘MM/DD/RR HH24:MI:SS‘),10,2),‘23‘,1,0)) H23,
       COUNT(*) TOTAL
FROM v$log_history  a
   where first_time>=to_char(sysdate-11)
GROUP BY SUBSTR(TO_CHAR(first_time, ‘MM/DD/RR HH:MI:SS‘),1,5)
ORDER BY SUBSTR(TO_CHAR(first_time, ‘MM/DD/RR HH:MI:SS‘),1,5) DESC;

redo日志切换频率

时间: 2024-10-07 04:04:05

DBA日常SQL之查询数据库运行状况的相关文章

sql server 查询数据库所有的表名+字段

原文:sql server 查询数据库所有的表名+字段 SELECT * FROM INFORMATION_SCHEMA.columns WHERE TABLE_NAME='Account' SELECT    (case when a.colorder=1 then d.name else '' end) as 表名,--如果表名相同就返回空       a.colorder as 字段序号,       a.name as 字段名,       (case when COLUMNPROPER

SQL Server查询数据库空间分配情况、数据库备份信息

查询数据库空间分配情况: 1 use master 2 go 3 create procedure dbo.proc_getdbspaceused 4 as 5 begin 6 set nocount on 7 create table #dbsize( 8 database_id int 9 ,database_name nvarchar(1024) 10 ,size_kb bigint 11 ,space_available_kb bigint 12 ,reserved_kb bigint

sql语句查询数据库表结构信息

开发中经常用到查询指定表及其字段的信息,以下是我整理的SQL语句查询方法,供自己平时使用也提供给大家参考! 1.适用MS SQL SERVER: 1 SELECT 2 表名 = case when a.colorder=1 then d.name else '' end, 3 表说明 = case when a.colorder=1 then isnull(f.value,'') else '' end, 4 字段序号 = a.colorder, 5 字段名 = a.name, 6 标识 = c

SQL Server —— 查询数据库、表、列等

一.查询数据库(sys.databases -- select *from sys.databases where name='<数据库名>') select *from sys.databases where name='MyDatabase' 二.查询表(sysobjects -- select *from sysobjects where id=OBJECT_ID('<表名>')) select *from sysobjects where id=OBJECT_ID('Stu

【手记】解决EXCEL跑SQL遇“查询无法运行或数据库表无法打开...”

报错: 解决:在语句开头指定SET NOCOUNT ON 就是这么神cao奇dan. -END-

hibernate用sql联合查询数据库

@RequestMapping(value = "/FeedPager.cqzk")     @ResponseBody     public String url_sa1(HttpServletRequest request, BootPage page)             throws ServletException, IOException, RuntimeException {         @SuppressWarnings("unchecked"

【转】SQL Server查询数据库所有存储过程、触发器、索引信息SQL分享

1. 查询所有存储过程 select Pr_Name as [存储过程], [参数]=stuff((select ','+[Parameter] from ( select Pr.Name as Pr_Name,parameter.name +' ' +Type.Name + ' ('+convert(varchar(32),parameter.max_length)+')' as Parameter from sys.procedures Pr left join sys.parameters

SQL Server查询数据库近期执行的SQL语句

SELECT TOP 1000        ST.text AS '执行的SQL语句',       QS.execution_count AS '执行次数',       QS.total_elapsed_time AS '耗时',       QS.total_logical_reads AS '逻辑读取次数',       QS.total_logical_writes AS '逻辑写入次数',       QS.total_physical_reads AS '物理读取次数',    

SQL Server 查询数据库表的列数

1 select count(*) from sysobjects a 2 join syscolumns b 3 on a.id=b.id 4 where a.name='表名' 5 go