以下脚本可以用于检测数据库当前是否有备份操作在执行中:
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 /
我测试了一下:一个窗口执行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
你好 脚本已经修改过了.
看来是要分单实例还是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