oracle_DBA 管理之归档日志管理sql
2018-09-10 10:03
597 查看
查当天每小时的归档日志生成量 select logtime, count(*), round(sum(blocks * block_size) / 1024 / 1024) mbsize from (select trunc(first_time, 'hh') as logtime, a.BLOCKS, a.BLOCK_SIZE from v$archived_log a where a.DEST_ID = 1 and a.FIRST_TIME > trunc(sysdate)) group by logtime order by logtime desc; 查最近一周每天的归档日志生成量 select logtime, count(*), round(sum(blocks * block_size) / 1024 /1024) MBsize from (select trunc(first_time, 'dd') as logtime, a.BLOCKS, a.BLOCK_SIZE from v$archived_log a where a.DEST_ID = 1 and a.FIRST_TIME > trunc(sysdate - 15)) group by logtime order by logtime desc; 如果你需要知道RAC下各个节点的归档日志情况,我将上面脚本略作修改,增加thread#列。 select to_char(COMPLETION_TIME,'yyyy-mm-dd') tt, round(sum(blocks * block_size) / 1024 /1024/1024) GBsize from v$archived_log a where a.COMPLETION_TIME > date '2017-11-15' group by to_char(COMPLETION_TIME,'yyyy-mm-dd') order by to_char(COMPLETION_TIME,'yyyy-mm-dd') ; 查当天每小时的各个实例的归档日志生成量 select THREAD#, logtime, count(*), round(sum(blocks * block_size) / 1024 / 1024/1024,2) gb_size from (select a.THREAD#, trunc(first_time, 'hh') as logtime, a.BLOCKS, a.BLOCK_SIZE from v$archived_log a where a.DEST_ID = 1 and a.FIRST_TIME > trunc(sysdate)) group by THREAD#, logtime order by THREAD#, logtime desc; 查最近一周每天的各个实例的归档日志生成量 select THREAD#, logtime, count(*), round(sum(blocks * block_size) / 1024 / 1024) mbsize from (select THREAD#, trunc(first_time, 'dd') as logtime, a.BLOCKS, a.BLOCK_SIZE from v$archived_log a where a.DEST_ID = 1 and a.FIRST_TIME > trunc(sysdate - 7)) group by THREAD#, logtime order by THREAD#, logtime desc; 归档频率 set line 200 select b.SEQUENCE#, b.FIRST_TIME,a.SEQUENCE#,a.FIRST_TIME,round(((a.FIRST_TIME-b.FIRST_TIME)*24)*60,2) from v$log_history a, v$log_history b where a.SEQUENCE#=b.SEQUENCE#+1 and b.THREAD#=1 order by a.SEQUENCE# desc; -----查看REDO产生量情况 select a.sid,value/1024/1024/1024,c.sql_id,c.status,C.EVENT,c.username,d.SQL_FULLTEXT from v$sesstat a, v$statname b ,v$session c ,v$sql d where a.statistic#=b.statistic# and a.sid=c.sid and c.sql_id=d.sql_id(+) and b.name = 'redo size' and c.wait_class<>'idle' order by 2 desc; FRA 归档 Flash back 日志量很大分析 select INST_ID,OLDEST_FLASHBACK_SCN,OLDEST_FLASHBACK_TIME,RETENTION_TARGET,FLASHBACK_SIZE/1024/1024/1024 GB ,ESTIMATED_FLASHBACK_SIZE/1024/1024/1024 ESTF_GB from gv$flashback_database_log ; select a.BEGIN_TIME,a.END_TIME,round(a.FLASHBACK_DATA/1024/1024/1024,2) FLASHBACK_DATA_GB,round(a.DB_DATA/1024/1024/1024,2 )DB_DATA_GB, a.REDO_DATA,round(a.ESTIMATED_FLASHBACK_SIZE/1024/1024/1024 ,2)est_size_GB from V$FLASHBACK_DATABASE_STAT a; 2 select to_char(first_time,'yyyy-mm-dd') archive_date, cast((sum(blocks*block_size)/1024/1024/1024) as number(10,2)) day_size_gb, cast((sum(case when to_char(first_time,'hh24')=00 then blocks*block_size else 0 end)/1024/1024/1024) as number(10,2)) h_00_size, cast((sum(case when to_char(first_time,'hh24')=01 then blocks*block_size else 0 end)/1024/1024/1024) as number(10,2)) h_01_size, cast((sum(case when to_char(first_time,'hh24')=02 then blocks*block_size else 0 end)/1024/1024/1024) as number(10,2)) h_02_size, cast((sum(case when to_char(first_time,'hh24')=03 then blocks*block_size else 0 end)/1024/1024/1024) as number(10,2)) h_03_size, cast((sum(case when to_char(first_time,'hh24')=04 then blocks*block_size else 0 end)/1024/1024/1024) as number(10,2)) h_04_size, cast((sum(case when to_char(first_time,'hh24')=05 then blocks*block_size else 0 end)/1024/1024/1024) as number(10,2)) h_05_size, cast((sum(case when to_char(first_time,'hh24')=06 then blocks*block_size else 0 end)/1024/1024/1024) as number(10,2)) h_06_size, cast((sum(case when to_char(first_time,'hh24')=07 then blocks*block_size else 0 end)/1024/1024/1024) as number(10,2)) h_07_size, cast((sum(case when to_char(first_time,'hh24')=08 then blocks*block_size else 0 end)/1024/1024/1024) as number(10,2)) h_08_size, cast((sum(case when to_char(first_time,'hh24')=09 then blocks*block_size else 0 end)/1024/1024/1024) as number(10,2)) h_09_size, cast((sum(case when to_char(first_time,'hh24')=10 then blocks*block_size else 0 end)/1024/1024/1024) as number(10,2)) h_10_size, cast((sum(case when to_char(first_time,'hh24')=11 then blocks*block_size else 0 end)/1024/1024/1024) as number(10,2)) h_11_size, cast((sum(case when to_char(first_time,'hh24')=12 then blocks*block_size else 0 end)/1024/1024/1024) as number(10,2)) h_12_size, cast((sum(case when to_char(first_time,'hh24')=13 then blocks*block_size else 0 end)/1024/1024/1024) as number(10,2)) h_13_size, cast((sum(case when to_char(first_time,'hh24')=14 then blocks*block_size else 0 end)/1024/1024/1024) as number(10,2)) h_14_size, cast((sum(case when to_char(first_time,'hh24')=15 then blocks*block_size else 0 end)/1024/1024/1024) as number(10,2)) h_15_size, cast((sum(case when to_char(first_time,'hh24')=16 then blocks*block_size else 0 end)/1024/1024/1024) as number(10,2)) h_16_size, cast((sum(case when to_char(first_time,'hh24')=17 then blocks*block_size else 0 end)/1024/1024/1024) as number(10,2)) h_17_size, cast((sum(case when to_char(first_time,'hh24')=18 then blocks*block_size else 0 end)/1024/1024/1024) as number(10,2)) h_18_size, cast((sum(case when to_char(first_time,'hh24')=19 then blocks*block_size else 0 end)/1024/1024/1024) as number(10,2)) h_19_size, cast((sum(case when to_char(first_time,'hh24')=20 then blocks*block_size else 0 end)/1024/1024/1024) as number(10,2)) h_20_size, cast((sum(case when to_char(first_time,'hh24')=21 then blocks*block_size else 0 end)/1024/1024/1024) as number(10,2)) h_21_size, cast((sum(case when to_char(first_time,'hh24')=22 then blocks*block_size else 0 end)/1024/1024/1024) as number(10,2)) h_22_size, cast((sum(case when to_char(first_time,'hh24')=23 then blocks*block_size else 0 end)/1024/1024/1024) as number(10,2)) h_23_size, sum(case when to_char(first_time,'hh24')=00 then 1 else 0 end) h00_logs, sum(case when to_char(first_time,'hh24')=01 then 1 else 0 end) h01_logs, sum(case when to_char(first_time,'hh24')=02 then 1 else 0 end) h02_logs, sum(case when to_char(first_time,'hh24')=03 then 1 else 0 end) h03_logs, sum(case when to_char(first_time,'hh24')=04 then 1 else 0 end) h04_logs, sum(case when to_char(first_time,'hh24')=05 then 1 else 0 end) h05_logs, sum(case when to_char(first_time,'hh24')=06 then 1 else 0 end) h06_logs, sum(case when to_char(first_time,'hh24')=07 then 1 else 0 end) h07_logs, sum(case when to_char(first_time,'hh24')=08 then 1 else 0 end) h08_logs, sum(case when to_char(first_time,'hh24')=09 then 1 else 0 end) h09_logs, sum(case when to_char(first_time,'hh24')=10 then 1 else 0 end) h10_logs, sum(case when to_char(first_time,'hh24')=11 then 1 else 0 end) h11_logs, sum(case when to_char(first_time,'hh24')=12 then 1 else 0 end) h12_logs, sum(case when to_char(first_time,'hh24')=13 then 1 else 0 end) h13_logs, sum(case when to_char(first_time,'hh24')=14 then 1 else 0 end) h14_logs, sum(case when to_char(first_time,'hh24')=15 then 1 else 0 end) h15_logs, sum(case when to_char(first_time,'hh24')=16 then 1 else 0 end) h16_logs, sum(case when to_char(first_time,'hh24')=17 then 1 else 0 end) h17_logs, sum(case when to_char(first_time,'hh24')=18 then 1 else 0 end) h18_logs, sum(case when to_char(first_time,'hh24')=19 then 1 else 0 end) h19_logs, sum(case when to_char(first_time,'hh24')=20 then 1 else 0 end) h20_logs, sum(case when to_char(first_time,'hh24')=21 then 1 else 0 end) h21_logs, sum(case when to_char(first_time,'hh24')=22 then 1 else 0 end) h22_logs, sum(case when to_char(first_time,'hh24')=23 then 1 else 0 end) h23_logs from v$archived_log where standby_dest='NO' and first_time > trunc(sysdate)-60 group by to_char(first_time,'yyyy-mm-dd') order by archive_date desc;
相关文章推荐
- oracle-dba- 管理归档日志
- ORACLE DBA学习笔记--管理归档日志文件
- ORACLE DBA学习笔记--管理归档日志文件
- Oracle归档日志管理技巧
- Oracle的DBA管理常用sql
- oracle dba系统管理的有用sql
- Oracle管理归档日志文件
- Oracle归档日志管理
- ORACLE 使用RMAN管理归档日志 archived log
- oracle-dba- 重做日志管理
- oracle归档日志管理 (收集)
- ORACLE 使用RMAN管理归档日志 archived log
- Oracle归档日志管理
- [Oracle管理] DBA常用数据库管理SQL (摘录整理)
- oracle管理归档日志文件
- [Oracle] DBA管理之"中止事务和修改日志回滚组"
- oracle客户端数据库管理工具乱码(pl/sql、dba)
- 高级SQL优化(一) ——《12年资深DBA教你Oracle开发与优化——性能优化部分》
- Oracle丢失归档日志文件的数据库恢复方法
- oracle 11g归档日志研究_3