如何在Oracle中查看各个表,表空间占用空间的大小
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何在Oracle中查看各个表,表空间占用空间的大小相关的知识,希望对你有一定的参考价值。
在Oracle中查看各表及表空间占用空间大小可用sql语句执行查看。
Oracle版本:Oracle 10g
一、查看表占用空间大小语句:
select t.segment_name, t.segment_type, sum(t.bytes / 1024 / 1024) "占用空间(M)"from dba_segments t
where t.segment_type=\'TABLE\'
group by OWNER, t.segment_name, t.segment_type;
查询结果:
二、查看表空间占用空间大小语句:
select a.tablespace_name,a.bytes/1024/1024 "Sum MB",(a.bytes-b.bytes)/1024/1024 "used MB",b.bytes/1024/1024 "free MB",round(((a.bytes-b.bytes)/a.bytes)*100,2) "percent_used"from
(select tablespace_name,sum(bytes) bytes from dba_data_files group by tablespace_name) a,
(select tablespace_name,sum(bytes) bytes,max(bytes) largest from dba_free_space group by tablespace_name) b
where a.tablespace_name=b.tablespace_name
order by ((a.bytes-b.bytes)/a.bytes) desc
查询结果:
Select Segment_Name,Sum(bytes)/1024/1024 From User_Extents Group By Segment_Name
使用一下语句查看每个表空间占用空间的大小:
Select Tablespace_Name,Sum(bytes)/1024/1024 From Dba_Segments Group By Tablespace_Name
Oracle查看表占用空间
Oracle查看表占用空间
查看表空间对应日志文件
select
tablespace_name, file_id, file_name,
round(bytes/(1024*1024),0) total_space
from dba_data_files
order by tablespace_name;
查看表空间总大小、使用率、剩余空间
select
a.tablespace_name, total, free, total-free as used, substr(free/total * 100, 1, 5) as "FREE%", substr((total - free)/total * 100, 1, 5) as "USED%"
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;
查看具体表的占用空间大小
select * from (
select t.tablespace_name,t.owner, t.segment_name, t.segment_type, sum(t.bytes / 1024 / 1024) mb
from dba_segments t
where t.segment_type='TABLE'
group by t.tablespace_name,t.OWNER, t.segment_name, t.segment_type
) t
order by t.mb desc;
以上是关于如何在Oracle中查看各个表,表空间占用空间的大小的主要内容,如果未能解决你的问题,请参考以下文章