Wednesday, May 21, 2014

Script to Identity database requires crash recovery or not

1. Script to identify crash recovery
select t.thread#,d.open_mode,t.status,i.instance_name,
case 
when((t.status='CLOSED') and (d.open_mode='MOUNTED')) THEN 'DB DON''T REQUIRE CRASH RECOVERY'
WHEN ((t.status='OPEN') and (d.open_mode='READ WRITE')) THEN 'DB IS OPEN'
WHEN ((t.status='OPEN') and (d.open_mode='MOUNTED')) THEN 'DB NEED CRASH RECOVERY'
ELSE 'NO IDEA'
END  "DB_STATUS"
from v$thread t,
v$database d,
v$instance i
where t.thread#=i.thread#;
2.output of the script output
SQL> select t.thread#,d.open_mode,t.status,i.instance_name,
  2  case
when((t.status='CLOSED') and (d.open_mode='MOUNTED')) THEN 'DB DON''T REQUIRE CRASH RECOVERY'
WHEN ((t.status='OPEN') and (d.open_mode='READ WRITE')) THEN 'DB IS OPEN'
  3    4    5  WHEN ((t.status='OPEN') and (d.open_mode='MOUNTED')) THEN 'DB NEED CRASH RECOVERY'
  6  ELSE 'NO IDEA'
  7  END  "DB_STATUS"
  8  from v$thread t,
  9  v$database d,
 10  v$instance i
 11  where t.thread#=i.thread#;

   THREAD# OPEN_MODE            STATUS INSTANCE_NAME    DB_STATUS
---------- -------------------- ------ ---------------- -------------------------------
         1 READ WRITE           OPEN   CVRMAN           DB IS OPEN

No comments: