Script:检查数据库当前是否有备份操作在执行中

Oracle ALLSTARS II夯实基础

加入dbDao.com Oracle技术学习QQ群:171092051

以下脚本可以用于检测数据库当前是否有备份操作在执行中:

SELECT DECODE(os_backup.backup + rman_backup.backup, 0, 'FALSE', 'TRUE') backup
  FROM (SELECT COUNT(*) backup FROM gv$backup WHERE status = 'ACTIVE') os_backup,
       (SELECT COUNT(*) backup
          FROM gv$session
         WHERE status = 'ACTIVE'
           AND client_info like '%rman%') rman_backup
/

dbDao.com 引导式IT在线教育

dbDao 百度贴吧:http://tieba.baidu.com/dbdao

扫码关注dbDao 微信公众号:

  1. 我测试了一下:一个窗口执行rman 备份,另一个窗口查看
    sys@RAC> SELECT DECODE(os_backup.backup + rman_backup.backup, 0, ‘FALSE’, ‘TRUE’) backup
    2 FROM (SELECT COUNT(*) backup FROM v$backup WHERE status = ‘ACTIVE’) os_backup,
    3 (SELECT COUNT(*) backup
    4 FROM v$session
    5 WHERE status = ‘ACTIVE’
    6 AND client_info like ‘%id=rman%’) rman_backup
    7 /

    BACKU
    —–
    FALSE

  2. 看来是要分单实例还是rac 数据库这两种情况
    sys@RAC> SELECT DECODE(os_backup.backup + rman_backup.backup, 0, ‘FALSE’, ‘TRUE’) backup
    2 FROM (SELECT COUNT(*) backup FROM gv$backup WHERE status = ‘ACTIVE’) os_backup,
    3 (SELECT COUNT(*) backup
    4 FROM gv$session
    5 WHERE status = ‘ACTIVE’
    6 AND client_info like ‘%rman%’) rman_backup
    7 /

    BACKU
    —–
    TRUE

  3. Pingback: Oracle数据恢复专题 – ORACLE数据库数据恢复、性能优化、故障诊断来问问MACLEAN