查询数据库表空间
程序员文章站
2024-03-21 14:19:16
...
select df.tablespace_name,
round(df.total_space / 1048576, 0) "Total Space(MB)",
round((df.total_space - nvl(fs.free_space, 0)) / 1048576, 0) "Used Space(MB)",
round(nvl(fs.free_space, 0) / 1048576, 0) "Free Space(MB)",
round(100 * (1 - nvl(fs.free_space, 0) / df.total_space), 2) "%Used",
to_char(Sysdate, 'yyyy-mm-dd hh24:mi') Stat_Time
from (select tablespace_name, sum(bytes) total_space
from dba_data_files
group by tablespace_name) df,
(select b.tablespace_name, sum(b.bytes) free_space
from dba_free_space b
group by b.tablespace_name) fs
where df.tablespace_name = fs.tablespace_name(+)
and exists (select *
from dba_tablespaces ts
where ts.contents <> 'TEMPORARY'
and ts.tablespace_name = df.tablespace_name)
union
select df.tablespace_name,
round(df.total_space / 1048576, 0) "Total Space(MB)",
round(nvl(us.used_space, 0) / 1048576, 0) "Used Space(MB)",
round((df.total_space - nvl(us.used_space, 0)) / 1048576, 0) "Free Space(MB)",
round(100 * (nvl(us.used_space, 0) / df.total_space), 2) "%Used",
to_char(Sysdate, 'yyyy-mm-dd hh24:mi') Stat_Time
from (select tablespace_name, sum(bytes) total_space
from dba_temp_files
group by tablespace_name) df,
(select b.tablespace_name, sum(b.bytes_cached) used_space
from v$temp_extent_pool b
group by b.tablespace_name) us
where df.tablespace_name = us.tablespace_name(+)
and exists (select *
from dba_tablespaces ts
where ts.contents = 'TEMPORARY'
and ts.tablespace_name = df.tablespace_name)
order by 5 desc;
!
转载于:https://blog.51cto.com/bjdong/1718632
上一篇: 联系人 列表