码迷,mamicode.com
首页 > 数据库 > 详细

dba常用SQL语句

时间:2020-02-22 14:06:25      阅读:76      评论:0      收藏:0      [点我收藏+]

标签:cas   常用sql   archive   max   --   bsp   tap   desc   UNC   

查询rman备份集
SELECT TRIM(START_TIME||#), TRIM(END_TIME||#), TRIM(CASE OUTPUT_DEVICE_TYPE WHEN DISK THEN DISK WHEN SBT_TAPE THEN SBT_TAPE ELSE Others END||#) AS BACKUP_DEVICE, TRIM(STATUS||#), TRIM(CASE INPUT_TYPE WHEN DB FULL THEN DB_FULL WHEN DB INCR THEN DB_INCR WHEN ARCHIVELOG THEN DB_ARCH ELSE Others END||#) AS BACKUP_TYPE, TRIM(ROUND(ELAPSED_SECONDS / 60 / 60, 2)||#) AS T, TRIM(OUTPUT_BYTES_DISPLAY||#) AS DB_SIZE FROM V$RMAN_BACKUP_JOB_DETAILS WHERE START_TIME = (SELECT MAX(START_TIME) FROM V$RMAN_BACKUP_JOB_DETAILS);
---11G 使用SYS 用户可以直接查询结果;12C 需要在CDB 使用SYS用户查询,否则没有结构
-- 查询归档日志最大值和平均值
select max(ss.size_GB), avg(ss.size_GB)
  from (select s.*, rownum rn2
          from (select a.*
                  from (select t1.*, rownum rn
                          from (SELECT TRUNC(FIRST_TIME) time,
                                       SUM(BLOCK_SIZE * BLOCKS) / 1024 / 1024 / 1024 size_GB
                                  FROM V$ARCHIVED_LOG
                                 GROUP BY TRUNC(FIRST_TIME)
                                 order by time desc) t1) a
                 where a.rn > 1
                 order by a.time asc) s) ss
 where ss.rn2 > 1;

 

----查询ASM使用率
select group_number,name,total_mb/1024 TGB,free_mb/1024 FGB,USABLE_FILE_MB/1024  from v$asm_diskgroup;

 
---RAC 查询单节点日归档大小
select to_char(b.FIRST_TIME, yyyy-mm-dd) arch_date,
       round(sum(b.BLOCKS * b.BLOCK_SIZE / 1024 / 1024/1024), 2) "ARCH_SIZE(GB)"
  from v$archived_log b
 where b.CREATOR = ARCH
   and b.STANDBY_DEST = NO
   and b.archived = YES
   and b.dest_id = 1
   and b.FIRST_TIME >= sysdate - 15
   and b.FIRST_TIME < trunc(sysdate)
 group by to_char(FIRST_TIME, yyyy-mm-dd)
 order by 1;

 

dba常用SQL语句

标签:cas   常用sql   archive   max   --   bsp   tap   desc   UNC   

原文地址:https://www.cnblogs.com/vmsysjack/p/12344818.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!