Thursday, June 19, 2014

Oracle Database health check

select name,open_mode from v$database;
REM '################################Tablespace Usage#####################################'
select count(*), status from v$session group by status;
set pagesize 500
REM '################################Tablespace Usage#####################################'
col TABLESPACE_NAME FORMAT A15
  ttitle 'Tablespace Growth'
  select a.TABLESPACE_NAME,
           a.BYTES MB_USED,
           b.BYTES MB_FREE,
           b.LARGEST,
           round(((a.BYTES - b.BYTES)/a.BYTES)*100,2) percent_used
    from
           (
           select TABLESPACE_NAME,
                  sum(BYTES/1024/1024) bytes
           from   dba_data_files
           group  by TABLESPACE_NAME
           ) a,
           (
           select TABLESPACE_NAME ,
                  sum(BYTES/1024/1024) bytes,
                  max(BYTES/1024/1024) largest
           from   dba_free_space
           group  by TABLESPACE_NAME
           ) b
   where   a.TABLESPACE_NAME = b.TABLESPACE_NAME
order by ((a.BYTES - b.BYTES)/a.BYTES) desc;
  ttitle off
ttitle 'TEMPORAY TBS'
select bytes_used/1024/1024 "USED",bytes_free/1024/1024 "FREE",tablespace_name from v$temp_space_header;
ttitle off
select tablespace_name,total_blocks,used_blocks,free_blocks from v$sort_segment;
REM '################################Tablespace Usage#####################################'

No comments: