Search This Blog

Total Pageviews

Thursday 10 March 2022

Tablespace info ..

 Tablespace info .. ....

set head off verify off echo off pages 1500 linesize 110 feedback off alter session set nls_date_format='DD-MM-YYYY HH24:MI:SS'; select 'TABLESPACE_NAME......................................: '||TABLESPACE_NAME , 'BLOCK_SIZE...........................................: '||BLOCK_SIZE , 'INITIAL_EXTENT.......................................: '||INITIAL_EXTENT , 'NEXT_EXTENT..........................................: '||NEXT_EXTENT , 'MIN_EXTENTS..........................................: '||MIN_EXTENTS , 'MAX_EXTENTS..........................................: '||MAX_EXTENTS , 'MAX_SIZE.............................................: '||MAX_SIZE , 'PCT_INCREASE.........................................: '||PCT_INCREASE , 'MIN_EXTLEN...........................................: '||MIN_EXTLEN , 'STATUS...............................................: '||STATUS , 'CONTENTS.............................................: '||CONTENTS , 'LOGGING..............................................: '||LOGGING , 'FORCE_LOGGING........................................: '||FORCE_LOGGING , 'EXTENT_MANAGEMENT....................................: '||EXTENT_MANAGEMENT , 'ALLOCATION_TYPE......................................: '||ALLOCATION_TYPE , 'PLUGGED_IN...........................................: '||PLUGGED_IN , 'SEGMENT_SPACE_MANAGEMENT ..........................: '||SEGMENT_SPACE_MANAGEMENT , 'DEF_TAB_COMPRESSION..................................: '||DEF_TAB_COMPRESSION , 'RETENTION............................................: '||RETENTION , 'BIGFILE..............................................: '||BIGFILE , 'PREDICATE_EVALUATION.................................: '||PREDICATE_EVALUATION, 'ENCRYPTED............................................: '||ENCRYPTED , 'COMPRESS_FOR ........................................: '||COMPRESS_FOR , 'DEF_INMEMORY.........................................: '||DEF_INMEMORY , 'DEF_INMEMORY_PRIORITY................................: '||DEF_INMEMORY_PRIORITY , 'DEF_INMEMORY_DISTRIBUTE.............................: '||DEF_INMEMORY_DISTRIBUTE , 'DEF_INMEMORY_COMPRESSION.............................: '||DEF_INMEMORY_COMPRESSION , 'DEF_INMEMORY_DUPLICATE...............................: '||DEF_INMEMORY_DUPLICATE , 'SHARED...............................................: '||SHARED , 'DEF_INDEX_COMPRESSION ...............................: '||DEF_INDEX_COMPRESSION , 'INDEX_COMPRESS_FOR...................................: '||INDEX_COMPRESS_FOR , 'DEF_CELLMEMORY ......................................: '||DEF_CELLMEMORY , 'DEF_INMEMORY_SERVICE.................................: '||DEF_INMEMORY_SERVICE , 'DEF_INMEMORY_SERVICE_NAME............................: '||DEF_INMEMORY_SERVICE_NAME, 'LOST_WRITE_PROTECT...................................: '||LOST_WRITE_PROTECT , 'CHUNK_TABLESPACE ....................................: '||CHUNK_TABLESPACE from dba_tablespaces where 1=1 -- and TABLESPACE_NAME='XXX' ;





set linesize 300 pagesize 200
col TABLESPACE_NAME   for a25
col PERUSD            for 999999999
SELECT m.tablespace_name,
    round(max(m.used_percent),1)                                                                                  PERUSD,
    round(max(m.used_space*t.block_size)*100/(sum(d.bytes)*count(distinct d.file_id)/count(d.file_id)),1)         PERC,
    round(max(m.tablespace_size*t.block_size/1024/1024),1)                                                        TOTALM,
    round((sum(d.bytes)*count(distinct d.file_id))/count(d.file_id)/1024/1024,1)                                  TOTAL,
    round(max(m.used_space*t.block_size/1024/1024),1)                                                             USED,
    round(max((m.tablespace_size-m.used_space)*t.block_size/1024/1024),1)                                         FREEM,
    round(((sum(d.bytes)*count(distinct d.file_id))/count(d.file_id)-max(m.used_space*t.block_size))/1024/1024,1) FREE,    
    count(distinct d.file_id)                                                                                     DBF_NO,
    max(to_number(tt.warning_value))                                                                              WARN,
    max(to_number(tt.critical_value))                                                                             CRIT,
    max(case when m.used_percent>tt.warning_value OR m.used_percent>tt.critical_value then 'NO!' else 'OK' end) "OK?"
FROM  dba_tablespace_usage_metrics m, dba_tablespaces t, dba_data_files d, dba_thresholds tt
WHERE m.tablespace_name =t.tablespace_name
AND d.tablespace_name   =t.tablespace_name
and tt.metrics_name     ='Tablespace Space Usage'
and tt.object_name is null
-- and d.tablespace_name   ='DATA'
GROUP BY m.tablespace_name
order by 2 desc;




--- CDB 

set linesize 300 pagesize 200
col TABLESPACE_NAME   for a25
col PERUSD            for 999999999
SELECT m.tablespace_name,
    round(max(m.used_percent),1)                                                                                  PERUSD,
    round(max(m.used_space*t.block_size)*100/(sum(d.bytes)*count(distinct d.file_id)/count(d.file_id)),1)         PERC,
    round(max(m.tablespace_size*t.block_size/1024/1024),1)                                                        TOTALM,
    round((sum(d.bytes)*count(distinct d.file_id))/count(d.file_id)/1024/1024,1)                                  TOTAL,
    round(max(m.used_space*t.block_size/1024/1024),1)                                                             USED,
    round(max((m.tablespace_size-m.used_space)*t.block_size/1024/1024),1)                                         FREEM,
    round(((sum(d.bytes)*count(distinct d.file_id))/count(d.file_id)-max(m.used_space*t.block_size))/1024/1024,1) FREE,    
    count(distinct d.file_id)                                                                                     DBF_NO,
    max(to_number(tt.warning_value))                                                                              WARN,
    max(to_number(tt.critical_value))                                                                             CRIT,
    max(case when m.used_percent>tt.warning_value OR m.used_percent>tt.critical_value then 'NO!' else 'OK' end) "OK?"
FROM  dba_tablespace_usage_metrics m, dba_tablespaces t, dba_data_files d, dba_thresholds tt
WHERE m.tablespace_name =t.tablespace_name
AND d.tablespace_name   =t.tablespace_name
and tt.metrics_name     ='Tablespace Space Usage'
and tt.object_name is null
-- and d.tablespace_name   ='DATA'
GROUP BY m.tablespace_name
order by 2 desc;











Tablespace metadata !!!

http://anuj-singh.blogspot.com/2011/11/oracle-tablespace-metadata.html
http://anuj-singh.blogspot.com/   How to Check Tablespace Creation Time in Oracle



Oracle DBA

anuj blog Archive