본문 바로가기

DB/DBA

TABLESPACE 사용량 CHECK

select substr(t_tablespace_name ,1,22) as TABLESPACE_NAME,
       round(t_total_size/1024/1024) as TOTAL_SIZE,
       lpad(round((t_total_size-f_free_size)/1024/1024),6,' ')||'('||lpad(round((1-f_free_size/t_total_size)*100,.999),3,' ')||'%)' as USED,
       lpad(round(f_free_size/1024/1024),6,' ')||'('||lpad(round(f_free_size/t_total_size*100,.999),3,' ')||'%)' as FREE,
       trunc(f_max_size/1024/1024) as MAX_FREE,
       trunc(e_next_extent/1024/1024) as NEXT_EXTENT
  from (
        select tablespace_name as t_tablespace_name,sum(bytes) as t_total_size
          from dba_data_files
         group by tablespace_name
       ),
       (
        select tablespace_name as f_tablespace_name,max(bytes) as f_max_size,sum(bytes) as f_free_size
          from dba_free_space
         group by tablespace_name
       ),
       (
        select tablespace_name as e_tablespace_name, max(next_extent) as e_next_extent
          from dba_segments
         group by tablespace_name
        )
  where t_tablespace_name = f_tablespace_name(+)
   and t_tablespace_name  = e_tablespace_name(+);
  
[출처] TABLESPACE 사용량 CHECK |작성자 송가리