C/C++教程

Oracle 数据库表、表空间大小统计

本文主要是介绍Oracle 数据库表、表空间大小统计,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

1、查找特定表大小

select round(BYTES/1024/1024,2)||'M' from Dba_Segments where segment_name=upper('表名');

2、查找数据库中占用空间较大的对象

SELECT OWNER,SEGMENT_NAME,SUM(bytes/1024/1024/1024 ) sum from Dba_Segments group by owner,segment_name having sum(bytes/1024/1024/1024 )>2 order by 3 desc; 

3、统计Oracle数据库用户所有表的大小

 SELECT OWNER as "用户名", sum(BYTES) / 1024 / 1024 / 1024 as "所有表的大小(GB)"
  FROM DBA_SEGMENTS
 WHERE SEGMENT_NAME in (select t2.OBJECT_NAME
                          from dba_objects t2
                         where t2.OBJECT_TYPE = 'TABLE')
 group by OWNER order by 2 desc;

4、查看每个表空间的大小

 Select Tablespace_Name,Sum(bytes)/1024/1024 From Dba_Segments Group By Tablespace_Name order by 2 desc;

这篇关于Oracle 数据库表、表空间大小统计的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!