• 监控数据库表空间使用情况


    1.按用户查表空间使用情况 

    select a.tablespace_name 表空间名称,total_space/(1024*1024)  总量,free_space/(1024*1024)  剩余量, 
    trunc((free_space/total_space)*100)||'%' 剩余比例 
    from 
    (select tablespace_name,sum(bytes) free_space  from dba_free_space 
    group by tablespace_name) a, 
    (select tablespace_name,sum(bytes)  total_space from dba_data_files 
    group by tablespace_name) b 
    where a.tablespace_name = b.tablespace_name   order by (free_space/total_space ) 

    2.查询某个用户的表占用空间大小 
    select segment_name,segment_type,tablespace_name,bytes,initial_extent, 
    next_extent from dba_segments where owner='CAL'   order by bytes desc; 

    3.监控数据库表空间使用情况 

    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 
    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(+); 

  • 相关阅读:
    Java 常用工具类
    Shiro 分析
    Oracle 恢复表操作内容
    Struts2 中的配置文件 package name 、namespace 以及 对象方法调用
    MySql 修改字符集
    命名空间、静态函数、实例函数
    Eclipse Tomcate 热部署
    Java Json
    Mybatis 存储过程调用
    HDFS源码分析心跳汇报之数据结构初始化
  • 原文地址:https://www.cnblogs.com/zhncnblogs/p/15719890.html
Copyright © 2020-2023  润新知