摘要:
下文讲述oracle数据库中,获取表空间及数据表所占用表空间大小,如下所示:
查看oracle中表空间及表空间占用大小
select tablespace_name,
sum(bytes)/1024/1024 as "表空间MB"
from dba_data_files group by tablespace_name;
查看oracle中表空间硬盘文件大小
select tablespace_name,
file_id, file_name,
bytes/(1024*1024) as "物理文件大小MB"
from dba_data_files
order by tablespace_name;
查看oracle中表空间 使用大小 使用率 剩余大小的sql脚本
select a.tablespace_name,
total, free, total-free as "已使用大小",
substr(free/total * 100, 1, 5) as "空间大小",
substr((total - free)/total * 100, 1, 5) as "使用率"
from
(select tablespace_name, sum(bytes)/1024/1024 as total from dba_data_files group by tablespace_name) a,
(select tablespace_name, sum(bytes)/1024/1024 as free from dba_free_space group by tablespace_name) b
where a.tablespace_name = b.tablespace_name
order by a.tablespace_name;
查看oracle中 指定数据表所占用的空间大小的方法
---例:获取数据表 “maomao”所占用的空间大小
select t.segment_name,
t.segment_type,
sum(t.bytes / 1024 / 1024) "表占用大小MB"
from dba_segments t
where t.segment_type='TABLE'
and t.segment_name='maomao'
group by OWNER, t.segment_name, t.segment_type;