美文网首页
Oracle-查询表空间使用量

Oracle-查询表空间使用量

作者: feihonInk | 来源:发表于2020-03-01 17:54 被阅读0次

    查询表空间及其使用量,把表空间大小、数据文件大小、已使用量空间、表空间自由空间、表空间使用率都用MB的形式呈现,方便查看。

    select a.tablespace_name 表空间名称,
           round((a.maxbytes / 1024 / 1024), 2) "表空间大小 MB",
           round((a.bytes / 1024 / 1024), 2) "数据文件总大小 MB",
           round(((a.bytes - b.bytes) / 1024 / 1024), 2) "已使用空间 MB",
           round(((a.maxbytes - a.bytes + b.bytes) / 1024 / 1024), 2) "表空间自由空间 MB",
           round(((a.bytes - b.bytes) / a.maxbytes) * 100, 2) "表空间使用率"
      from (select tablespace_name, sum(bytes) bytes, sum(maxbytes) maxbytes
              from dba_data_files
             where maxbytes != 0
             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.maxbytes) desc;
    

    相关文章

      网友评论

          本文标题:Oracle-查询表空间使用量

          本文链接:https://www.haomeiwen.com/subject/mqkhkhtx.html