Friday, July 10, 2015

to get size of tablespace

to get size of tablespace

SYS.DBA_FREE_SPACE

select  tablespace_name,sum(bytes/1024/1024/1024) "in GB"
  from dba_free_space
  group by tablespace_name
  order by  1 desc


to get size of table

 select segment_name,sum(bytes/1024/1024/1024)
     from SYS.dba_segments
     where segment_name =:’TABLE_NAME’
      and segment_type='TABLE'
      group by segment_name


Table : sys.dba_data_files
--> to get the file size

to get table space size

SELECT   a.TABLESPACE_NAME,
           a.BYTES/1024/1024/1024 GB_used,
           b.BYTES/1024/1024/1024 GB_free,
           b.largest,
           ROUND ( ( (a.BYTES - b.BYTES) / a.BYTES) * 100, 2) percent_used
    FROM   (  SELECT   TABLESPACE_NAME, SUM (BYTES) BYTES
                FROM   dba_data_files
            GROUP BY   TABLESPACE_NAME) a,
           (  SELECT   TABLESPACE_NAME, SUM (BYTES) BYTES, MAX (BYTES) 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


No comments:

Post a Comment