1、表空间大小及使用率
select
a.a1 表空间名称,
c.c2 类型,
c.c3 区管理,
b.b2/1024/1024 表空间大小M,
(b.b2-a.a2)/1024/1024 已使用M,
substr((b.b2-a.a2)/b.b2*100,1,5)||'%' 利用率
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;
2、查看Oracle数据库中数据文件信息
select
b.file_name 物理文件名,
b.tablespace_name 表空间,
b.bytes/1024/1024 大小M,
(b.bytes-sum(nvl(a.bytes,0)))/1024/1024 已使用M,
substr((b.bytes-sum(nvl(a.bytes,0)))/(b.bytes)*100,1,5)||'%' 利用率
FROM dba_free_space a,dba_data_files b
WHERE a.file_id=b.file_id
GROUP BY b.tablespace_name,b.file_name,b.bytes
ORDER BY b.tablespace_name
ps:查看表空间下面某个表所占空间大小
select segment_name,bytes/1024/1024 from dba_segments where tablespace_name
='TBS_REPORT' and segment_type='TABLE';
3、查看临时表空间和数据库文件
select
a.tablespace_name 表空间名称,
b.bytes/1024/1024 大小M,
b.file_name 数据文件名
FROM dba_tablespaces a,dba_data_files b
WHERE a.tablespace_name=b.tablespace_name
AND a.contents='TEMPORARY';