水煮orale22——查询表空间使用信息以及表空间中的每个数据文件信息

1.查询一个表空间下每个数据文件的使用信息
select a.tablespace_name "TN",a.file_name "FD",a.bytes/1024/1024 "TOTAL(M)",(a.bytes-sum(nvl(b.bytes,0)))/1024/1024 "USED(M)",
substr((a.bytes-sum(nvl(b.bytes,0)))/a.bytes*100,1,5) "USED%"from dba_data_files a,dba_free_space b
where a.file_id=b.file_id and a.tablespace_name=upper('users') group by a.tablespace_name ,a.file_name,a.bytes;
2.查询一个表空间的使用信息
select
a.a1 "TN",
c.c2 类型,
c.c3 区管理,
b.b2/1024/1024 "T_TOTAL(M)",
(b.b2-a.a2)/1024/1024 "T_USED(M)",
substr((b.b2-a.a2)/b.b2*100,1,5) "T_USED%"
from
(select  tablespace_name a1, sum(nvl(bytes,0)) a2 from dba_free_space group by tablespace_name) a,
(select tablespace_name b1,sum(bytes) b2 from dba_data_files group by tablespace_name) b,
(select tablespace_name c1,contents c2,extent_management c3  from dba_tablespaces) c
where a.a1=b.b1 and c.c1=b.b1 and a.a1=upper('users');
请使用浏览器的分享功能分享到微信等