0% found this document useful (0 votes)
70 views2 pages

Database Uptime

This document contains two SQL queries. The first query selects data from the v$instance view including the hostname, instance name, startup time, and database uptime for each instance. The second longer query selects similar data from the gv$instance view including the instance number, name, hostname, startup time, status, and database uptime. It also includes the SHUTDOWN_PENDING and INSTANCE_ROLE columns.

Uploaded by

density449673
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views2 pages

Database Uptime

This document contains two SQL queries. The first query selects data from the v$instance view including the hostname, instance name, startup time, and database uptime for each instance. The second longer query selects similar data from the gv$instance view including the instance number, name, hostname, startup time, status, and database uptime. It also includes the SHUTDOWN_PENDING and INSTANCE_ROLE columns.

Uploaded by

density449673
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

set line 150

column Hostname format a30


column "Instance Name" format a30
column "Started At" format a30
column "Database Uptime" format a40
SELECT host_name as Hostname,
instance_name as "Instance Name",
to_char(startup_time,'DD-MON-YYYY HH24:MI:SS') as "Started_At",
floor(sysdate-startup_time)||'days(s)'||
trunc(24*((sysdate-startup_time)-trunc(sysdate-startup_time)))||'hour(s)'||
mod(trunc(1440*((sysdate-startup_time)-trunc(sysdate-startup_time))),60)
||'minute(s)'||
mod(trunc(86400*((sysdate-startup_time)-trunc(sysdate-
startup_time))),60)||'seconds' as "Database_Uptime" FROM v$instance;

##########################################################

set lines 500


col HOST_NAME for a20
col DATABASE_STATUS for a20
column "Database Uptime" format a80
col instance_name for a30
col INSTANCE_ROLE for a25
col STATUS for a20
col "Startup time" for a30
select instance_number,instance_name,host_name,to_char(startup_time,'DD-MON-YY
HH24:MI') "Startup time",floor(sysdate-startup_time)||'days(s)'||
trunc(24*((sysdate-startup_time)-trunc(sysdate-startup_time)))||'hour(s)'||
mod(trunc(1440*((sysdate-startup_time)-trunc(sysdate-startup_time))),60)
||'minute(s)'||
mod(trunc(86400*((sysdate-startup_time)-trunc(sysdate-
startup_time))),60)||'seconds' as
"Database_Uptime",status,SHUTDOWN_PENDING,DATABASE_STATUS,INSTANCE_ROLE from
gv$instance;

##############################################################
Measuring the volume of Oracle redo size

The redo size Oracle metric is the total amount of redo generated in bytes.

Mark Rittman notes on redo log sizing says that increasing REDO Log size and
log_buffer parameter will reduce log switch waits and improve overall time for OLAP
operations.

This complex query will show redo size by time period:

col begin_interval_time format a30


set lines 160 pages 1000
col end_interval_time format a30
set colsep '|'
alter session set nls_date_format='DD-MON-YYYY';
with redo_sz as (
SELECT sysst.snap_id, sysst.instance_number, begin_interval_time
,end_interval_time , startup_time,
VALUE - lag (VALUE) OVER ( PARTITION BY startup_time, sysst.instance_number
ORDER BY begin_interval_time, startup_time, sysst.instance_number)
stat_value,
EXTRACT (DAY FROM (end_interval_time-begin_interval_time))*24*60*60+
EXTRACT (HOUR FROM (end_interval_time-begin_interval_time))*60*60+
EXTRACT (MINUTE FROM (end_interval_time-begin_interval_time))*60+
EXTRACT (SECOND FROM (end_interval_time-begin_interval_time)) DELTA
FROM sys.wrh$_sysstat sysst , DBA_HIST_SNAPSHOT snaps
WHERE (sysst.dbid, sysst.stat_id) IN ( SELECT dbid, stat_id FROM sys.wrh$_stat_name
WHERE stat_name='redo size' )
AND snaps.snap_id = sysst.snap_id
AND snaps.dbid =sysst.dbid
AND sysst.instance_number=snaps.instance_number
and begin_interval_time > sysdate-90
)
select instance_number,
to_date(to_char(begin_interval_time,'DD-MON-YYYY'),'DD-MON-YYYY') dt
, sum(stat_value) redo1
from redo_sz
group by instance_number,
to_date(to_char(begin_interval_time,'DD-MON-YYYY'),'DD-MON-YYYY')
order by instance_number, 2;

You might also like