水煮orale22——查詢表空間使用資訊以及表空間中的每個資料檔案資訊

1向2飛發表於2013-04-07
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');

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/23890223/viewspace-757877/,如需轉載,請註明出處,否則將追究法律責任。

相關文章