码迷,mamicode.com
首页 > 数据库 > 详细

三、查看Oracle表空间使用情况

时间:2019-01-05 11:15:37      阅读:222      评论:0      收藏:0      [点我收藏+]

标签:round   sele   空闲   select   tables   tab   bsp   容量   ora   

1、查询表空间的总容量

select a.TABLESPACE_NAME, sum(a.BYTES) / 1024 / 1024 as MB
  from sys.dba_data_files a
 group by a.TABLESPACE_NAME

2、查询表空间的空闲容量

select b.TABLESPACE_NAME,
       count(1) as extends,
       sum(b.BYTES) / 1024 / 1024 as MB,
       sum(b.BLOCKS) as blocks
  from sys.dba_free_space b
 group by b.TABLESPACE_NAME

3、查询表空间的使用情况

select total.TABLESPACE_NAME,
       round(total.MB, 2) as TOTAL_MB,
       round(total.MB - free.MB, 2) as USED_MB,
       ROUND((1 - free.MB / total.MB) * 100, 2) || % as USED_PCT,
       ROUND(free.MB, 2) as FREE_mb
  from (select a.TABLESPACE_NAME, sum(a.BYTES) / 1024 / 1024 as MB
          from sys.dba_data_files a
         group by a.TABLESPACE_NAME) total,
       (select b.TABLESPACE_NAME,
               count(1) as extends,
               sum(b.BYTES) / 1024 / 1024 as MB,
               sum(b.BLOCKS) as blocks
          from sys.dba_free_space b
         group by b.TABLESPACE_NAME) free
 where total.TABLESPACE_NAME = free.TABLESPACE_NAME

 

三、查看Oracle表空间使用情况

标签:round   sele   空闲   select   tables   tab   bsp   容量   ora   

原文地址:https://www.cnblogs.com/beanbag/p/10223610.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!