oracle中表空间的使用情况脚本

发布时间:2020-07-27 11:53:00 作者:ElanAir
来源:网络 阅读:475
  1.        select a.tablespace_name "tbsname", 100-round((nvl(b.bytes_free,0)/a.bytes_alloc)*100,2) "ratio",
           round(a.bytes_alloc/1024/1024,2) "size(M)", round(nvl(b.bytes_free,0)/1024/1024,2) "free(M)",
           round((a.bytes_alloc-nvl(b.bytes_free,0))/1024/1024,2) "usedM)", to_char(sysdate,'yyyy-mm-dd hh34:mi:ss') "get_time"
     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
    order by 2;

2.

        SELECT D.TABLESPACE_NAME,SPACE "SUM_SPACE(M)",BLOCKS
SUM_BLOCKS,SPACE-NVL(FREE_SPACE,0) "USED_SPACE(M)",
ROUND((1-NVL(FREE_SPACE,0)/SPACE)*100,2) "USED_RATE(%)",FREE_SPACE
"FREE_SPACE(M)"
FROM
(SELECT TABLESPACE_NAME,ROUND(SUM(BYTES)/(1024*1024),2)
SPACE,SUM(BLOCKS) BLOCKS
FROM DBA_DATA_FILES
GROUP BY TABLESPACE_NAME) D,
(SELECT TABLESPACE_NAME,ROUND(SUM(BYTES)/(1024*1024),2) FREE_SPACE
FROM DBA_FREE_SPACE
GROUP BY TABLESPACE_NAME) F
WHERE D.TABLESPACE_NAME = F.TABLESPACE_NAME(+)
UNION ALL --if have tempfile
SELECT D.TABLESPACE_NAME,SPACE "SUM_SPACE(M)",BLOCKS SUM_BLOCKS,
USED_SPACE "USED_SPACE(M)",ROUND(NVL(USED_SPACE,0)/SPACE*100,2)
"USED_RATE(%)",
NVL(FREE_SPACE,0) "FREE_SPACE(M)"
FROM
(SELECT TABLESPACE_NAME,ROUND(SUM(BYTES)/(1024*1024),2)
SPACE,SUM(BLOCKS) BLOCKS
FROM DBA_TEMP_FILES
GROUP BY TABLESPACE_NAME) D,
(SELECT TABLESPACE_NAME,ROUND(SUM(BYTES_USED)/(1024*1024),2)
USED_SPACE,
ROUND(SUM(BYTES_FREE)/(1024*1024),2) FREE_SPACE
FROM V$TEMP_SPACE_HEADER
GROUP BY TABLESPACE_NAME) F
WHERE D.TABLESPACE_NAME = F.TABLESPACE_NAME(+)

推荐阅读:
  1. Oracle中分区表中表空间属性
  2. oracle 临时表空间使用情况

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

oracle 脚本 中表

上一篇:为什么虚拟机中VMware Tools选项变成灰色

下一篇:CSS图片格式

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》