oralce表空间使用情况查询

 1 select upper(f.tablespace_name) tablespace_name, --  表空间名,
 2        d.tot_grootte_mb tot_grootte_mb, --   表空间大小(g),
 3        d.tot_grootte_mb - f.total_bytes usedmb, ---已使用空间(g),
 4        to_char(round((d.tot_grootte_mb - f.total_bytes) / d.tot_grootte_mb * 100,
 5                      2),
 6                '990.99') || '%' usageratio, -- 使用比,
 7        f.total_bytes, -- 空闲空间(g),
 8        d.maxbytes --表空间最大能扩到多大
 9   from (select tablespace_name,
10                round(sum(bytes) / (1024 * 1024 * 1024), 3) total_bytes,
11                round(max(bytes) / (1024 * 1024 * 1024), 3) max_bytes
12           from sys.dba_free_space
13          group by tablespace_name) f,
14        (select dd.tablespace_name,
15                round(sum(dd.bytes) / (1024 * 1024 * 1024), 3) tot_grootte_mb,
16                round(dd.maxbytes / (1024 * 1024 * 1024), 3) maxbytes
17           from sys.dba_data_files dd
18          group by dd.tablespace_name, dd.maxbytes) d
19  where d.tablespace_name = f.tablespace_name
20  order by 2 desc

查询表空间所有相关信息sql:select * from dba_data_files;

dba_data_files视图字段说明

 

(0)
上一篇 2022年3月22日
下一篇 2022年3月22日

相关推荐