V$RMAN_STATUS 视图使用

1. 查看最近1周内,数据库的备份情况

set tab off
set line 999
col operation for a10
col status for a10

select
    operation,
    status,
    object_type,
    to_char(start_time,'mm/dd/yyyy:hh:mi:ss') as start_time,
    to_char(end_time,'mm/dd/yyyy:hh:mi:ss') as end_time
from
    v$rman_status
where
    start_time > SYSDATE -7
and
    operation = 'BACKUP'
and
    object_type = 'DB FULL'
order by
    start_time desc;


OPERATION  STATUS     OBJECT_TYPE   START_TIME          END_TIME
---------- ---------- ------------- ------------------- -------------------
BACKUP     COMPLETED  DB FULL       11/27/2019:07:55:16 11/28/2019:02:21:14
BACKUP     COMPLETED  DB FULL       11/26/2019:07:55:43 11/27/2019:08:24:12
BACKUP     COMPLETED  DB FULL       11/26/2019:07:00:21 11/27/2019:07:11:25
BACKUP     COMPLETED  DB FULL       11/25/2019:07:00:19 11/26/2019:01:28:09
BACKUP     COMPLETED  DB FULL       11/24/2019:07:00:15 11/25/2019:01:32:29
BACKUP     COMPLETED  DB FULL       11/23/2019:07:00:18 11/24/2019:01:27:09
BACKUP     COMPLETED  DB FULL       11/23/2019:04:30:10 11/23/2019:07:21:19
BACKUP     COMPLETED  DB FULL       11/22/2019:07:00:15 11/23/2019:01:24:12
BACKUP     COMPLETED  DB FULL       11/22/2019:04:30:10 11/22/2019:07:15:56
BACKUP     COMPLETED  DB FULL       11/21/2019:07:00:15 11/22/2019:01:23:59

10 rows selected.

2. 查看RMAN运行状态

select to_char(start_time,'hh24:mi:ss') Start_Time,
   to_char(sysdate,'hh24:mi:ss') Time_Now,
       totalwork sofar,
       (sofar / totalwork) * 100 pct_done
  from v$session_longops
 where totalwork > sofar
   AND opname NOT LIKE '%aggregate%'
   AND opname like 'RMAN%';


SELECT SID, SERIAL#, CONTEXT, SOFAR, TOTALWORK,
ROUND(SOFAR/TOTALWORK*100,2) "%_COMPLETE"
FROM V$SESSION_LONGOPS
WHERE OPNAME LIKE 'RMAN%'
AND OPNAME NOT LIKE '%aggregate%'
AND TOTALWORK != 0
AND SOFAR <> TOTALWORK
/
点赞

发表评论

电子邮件地址不会被公开。必填项已用 * 标注