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

Oracle 表空间查询

时间:2014-09-30 16:22:29      阅读:319      评论:0      收藏:0      [点我收藏+]

标签:io   使用   sp   c   on   cti   r   bs   oracle   

一、普通查询

SELECT Total.name TablespaceName,
       Free_space,
       (total_space - Free_space) Used_space,
       total_space
  FROM (select tablespace_name, sum(bytes / 1024 / 1024) Free_Space
          from sys.dba_free_space
         group by tablespace_name) Free,
       (select b.name, sum(bytes / 1024 / 1024) TOTAL_SPACE
          from sys.v_$datafile a, sys.v_$tablespace B
         where a.ts# = b.ts#
         group by b.name) Total
 WHERE Free.Tablespace_name = Total.name;

 

二、根据Oracle 不活动连接用户查询使用空间

select t.owner 名称,sum(t.BYTES)/1024/1024/1024 使用大小_G from dba_segments t
where t.TABLESPACE_NAME=‘USERS‘ and t.owner not in(
select DISTINCT z.USERNAME from (
select t.USERNAME,DECODE(t.STATUS,‘INACTIVE‘,‘等待操作‘,‘ACTIVE‘,‘执行状态‘,‘KILLED‘,‘标注-KILL‘) 状态,
t.SCHEMA#,t.SCHEMANAME,t.MACHINE 机器名 from v$Session t where t.SCHEMANAME<>‘SYS‘ and t.SCHEMA#<>0
) z )
group by t.owner order by t.owner,sum(t.BYTES)/1024/1024/1024

Oracle 表空间查询

标签:io   使用   sp   c   on   cti   r   bs   oracle   

原文地址:http://www.cnblogs.com/wongs/p/4002044.html

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