'테이블스페이스 용량'에 해당되는 글 1건


Oracle 테이블스페이스 용량확인 스크립트



SELECT TABLESPACE_NAME,

       TOTAL_BYTES,

       USED_BYTES,

       FREE_BYTES,

       USED_RATE

FROM   (SELECT X.TABLESPACE_NAME,

               X.TOTAL_BYTES,

               X.USED_BYTES,

               X.FREE_BYTES,

               X.USED_RATE

        FROM   (SELECT A.TABLESPACE_NAME TABLESPACE_NAME,

                       SUBSTR(To_Char(Round(A.TOTAL_BYTES/1024000), '999,999,999'),2,11)||' MB ('||

                       SUBSTR(To_Char(Round(A.TOTAL_BYTES/1024000000, 2), '990.99'),2,6) ||' GB)' TOTAL_BYTES,

                       SUBSTR(To_Char(Round((A.TOTAL_BYTES-B.FREE_BYTES)/1024000), '999,999,999'),2,11)||' MB ('||

                       SUBSTR(To_Char(Round((A.TOTAL_BYTES-B.FREE_BYTES)/1024000000,2), '990.99'),2,6) ||' GB)' USED_BYTES,

                       SUBSTR(To_Char(Round(B.FREE_BYTES/1024000), '999,999,999'),2,11)||' MB ('||

                       SUBSTR(To_Char(Round(B.FREE_BYTES/1024000000, 2), '990.99'),2,6) ||' GB)' FREE_BYTES,

                       SUBSTR(To_Char(Round((A.TOTAL_BYTES-B.FREE_BYTES)/A.TOTAL_BYTES*100,2), '90.99'),2,5)||'%' USED_RATE

                FROM   (SELECT TABLESPACE_NAME, Sum(BYTES) TOTAL_BYTES

                        FROM   DBA_DATA_FILES

                        WHERE  TABLESPACE_NAME LIKE UPPER(DECODE('%','','%', '%'))

                        GROUP  BY TABLESPACE_NAME

                       )    A,

                       (SELECT TABLESPACE_NAME, Sum(BYTES) FREE_BYTES

                        FROM   USER_FREE_SPACE

                        WHERE  TABLESPACE_NAME LIKE UPPER(DECODE('%','','%', '%'))

                        GROUP  BY TABLESPACE_NAME

                       )    B

                WHERE  A.TABLESPACE_NAME = B.TABLESPACE_NAME

               )    X

        ORDER  BY DECODE('&TS_ORDER_BASE', '1', X.TABLESPACE_NAME, '', X.TABLESPACE_NAME, '2', X.USED_RATE) DESC

       )

       UNION ALL

       SELECT '------------------------------ ' TABLESPACE_NAME,

              '-------------------------- ' TOTAL_BYTES,

              '-------------------------- ' USED_BYTES,

              '-------------------------- ' FREE_BYTES,

              '----------' USED_RATE

       FROM   DUAL

       UNION ALL

       SELECT '전체' TABLESPACE_NAME,

              SUBSTR(To_Char(Round(A.TOTAL_BYTES/1024000), '999,999,999'),2,11)||' MB ('||

              SUBSTR(To_Char(Round(A.TOTAL_BYTES/1024000000, 2), '990.99'),2,6) ||' GB)' TOTAL_BYTES,

              SUBSTR(To_Char(Round((A.TOTAL_BYTES-B.FREE_BYTES)/1024000), '999,999,999'),2,11)||' MB ('||

              SUBSTR(To_Char(Round((A.TOTAL_BYTES-B.FREE_BYTES)/1024000000,2), '990.99'),2,6) ||' GB)' USED_BYTES,

              SUBSTR(To_Char(Round(B.FREE_BYTES/1024000), '999,999,999'),2,11)||' MB ('||

              SUBSTR(To_Char(Round(B.FREE_BYTES/1024000000, 2), '990.99'),2,6) ||' GB)' FREE_BYTES,

              SUBSTR(To_Char(Round((A.TOTAL_BYTES-B.FREE_BYTES)/A.TOTAL_BYTES*100,2), '90.99'),2,5)||'%' USED_RATE

       FROM   (SELECT Sum(BYTES) TOTAL_BYTES

               FROM   DBA_DATA_FILES

               WHERE  TABLESPACE_NAME LIKE UPPER(DECODE('%','','%', '%'))

              )     A,

              (SELECT Sum(BYTES) FREE_BYTES

               FROM   USER_FREE_SPACE

               WHERE  TABLESPACE_NAME LIKE UPPER(DECODE('%','','%', '%'))

              )     B

;


Select ts.tablespace_name, ts.status, ts.contents, ts.extent_management, ts.bigfile,

       size_info.megs_alloc, size_info.megs_free, size_info.megs_used,

       size_info.pct_free, size_info.pct_used, size_info.max

From

      (

      select  a.tablespace_name,

             round(a.bytes_alloc / 1024 / 1024) megs_alloc,

             round(nvl(b.bytes_free, 0) / 1024 / 1024) megs_free,

             round((a.bytes_alloc - nvl(b.bytes_free, 0)) / 1024 / 1024) megs_used,

             round((nvl(b.bytes_free, 0) / a.bytes_alloc) * 100) Pct_Free,

            100 - round((nvl(b.bytes_free, 0) / a.bytes_alloc) * 100) Pct_used,

             round(maxbytes/1048576) Max

      from  ( select  f.tablespace_name,

                     sum(f.bytes) bytes_alloc,

                     sum(decode(f.autoextensible, 'YES',f.maxbytes,'NO', f.bytes)) maxbytes

              from dba_data_files f

              group by tablespace_name) a,

            ( select  f.tablespace_name,

                     sum(f.bytes)  bytes_free

              from dba_free_space f

              group by tablespace_name) b

      where a.tablespace_name = b.tablespace_name (+)

      union all

      select h.tablespace_name,

             round(sum(h.bytes_free + h.bytes_used) / 1048576) megs_alloc,

             round(sum((h.bytes_free + h.bytes_used) - nvl(p.bytes_used, 0)) / 1048576) megs_free,

             round(sum(nvl(p.bytes_used, 0))/ 1048576) megs_used,

             round((sum((h.bytes_free + h.bytes_used) - nvl(p.bytes_used, 0)) / sum(h.bytes_used + h.bytes_free)) * 100) Pct_Free,

             100 - round((sum((h.bytes_free + h.bytes_used) - nvl(p.bytes_used, 0)) / sum(h.bytes_used + h.bytes_free)) * 100) pct_used,

             round(sum(f.maxbytes) / 1048576) max

      from   sys.v_$TEMP_SPACE_HEADER h, sys.v_$Temp_extent_pool p, dba_temp_files f

      where  p.file_id(+) = h.file_id

      and    p.tablespace_name(+) = h.tablespace_name

      and    f.file_id = h.file_id

      and    f.tablespace_name = h.tablespace_name

      group by h.tablespace_name

      ) size_info,

      sys.dba_tablespaces ts

where ts.tablespace_name = size_info.tablespace_name

;



블로그 이미지

운명을바꾸는자

IT와 함께 살아가는 삶

,