by http://webgeektutorials.blogspot.com

Monday, May 14, 2012

Oracle DBA Script : Display DB uptime

Displays DB start time, and calculates how long the DB has been up.

Code:
set head off pages 0
Select
'Current System time and date is '||
To_Char(sysdate,'HH24:MI:SS " on " ddth
FMMonth YYYY')||chr(10)||'Database
'||NAME||' has been up since '||
To_Char(To_Date(a.value||b.value,'JSSSSS')
,'HH24:MI:SS " on " ddth FMMonth YYYY')
||chr(10)||' ( Which is
'||Trunc(sysdate-to_date(a.value||b.value,'JSSSSS'))||' days '||To_Char(To_Date(trunc(86400*(
(sysdate-to_date(a.value||b.value,'JSSSSS')
)-trunc(sysdate-to_date(a.value||b.value,'JSSSS'
)))),'SSSSS')
,'HH24 "hours" MI "mins and" SS "seconds )"')
from v$instance a,v$instance b,v$database
where a.key='STARTUP TIME - JULIAN'
and b.key='STARTUP TIME - SECONDS';

No comments:

Post a Comment