查询Oracle表空间使用情况

参考文献
  1. dba_free_space : reference_link_for_dba_free_space
  2. dba_data_files : reference_link_for_dba_data_files
查询剩余表空间
SET lines 2000
SET pagesize 2000

SELECT tablespace_name,
       Count(*)                           AS extends,
       Round(Sum(bytes) / 1024 / 1024, 2) AS mb,
       Sum(blocks)                        AS blocks
FROM   dba_free_space
GROUP  BY tablespace_name
ORDER  BY tablespace_name;
查询表空间总容量
SET lines 2000
SET pagesize 2000

SELECT tablespace_name,
       Round(Sum(user_bytes) / 1024 / 1024, 2) AS mb
FROM   dba_data_files
GROUP  BY tablespace_name
ORDER  BY tablespace_name;
查询表空间使用率
SET lines 2000
SET pagesize 2000

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
FROM   (SELECT tablespace_name,
               Sum(bytes) / 1024 / 1024 AS mb
        FROM   dba_free_space
        GROUP  BY tablespace_name) free,
       (SELECT tablespace_name,
               Sum(user_bytes) / 1024 / 1024 AS mb
        FROM   dba_data_files
        GROUP  BY tablespace_name) total
WHERE  free.tablespace_name = total.tablespace_name
ORDER  BY tablespace_name;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值