Oracle查询表空间与表大小

转自:http://hi.baidu.com/cleimeng/item/93b25458dddd683f95eb0572

数据表的大小由段和区组成
当前用户下的可以使用下面SQL分别显示段和区信息:

select US.segment_name,us.bytes from user_segments us order by us.bytes desc;

select * from user_extents ue order by ue.bytes desc;

如果在DBA中查询某表空间(如CONFIG表空间)的表段和区的组成信息,使用SQL显示:

select ds.segment_name,ds.bytes from dba_segments ds where ds.tablespace_name='config' order by ds.bytes desc;

select * from dba_extents de where de.tablespace_name='config' order by de.bytes desc;

如果查询单个表记录:

select us.segment_name,us.bytes from user_segments us where us.segment_name='test_table'
order by us.bytes desc;

查看每个表空间的大小SQL:

select tablespace_name,sum(bytes)/1024/1024 from dba_segments group by tablespace_name;

查看整个系统的表空间大小SQL:

select upper(f.tablespace_name) "表空间名",d.tot_grootte_mb "表空间大小(M)",
d.tot_grootte_mb-f.total_bytes "已使用空间(M)",
to_char(round((d.tot_grootte_mb - f.total_bytes)/d.tot_grootte_mb*100,2),'990.99')||'%' "使用比",f.total_bytes "空闲空间(M)", f.max_bytes "最大块(M)" from (select tablespace_name,round(sum(bytes)/(1024*1024),2) total_bytes, round(max(bytes)/(1024*1024),2) max_bytes from sys.dba_free_space group by tablespace_name) f, (select dd.tablespace_name,round(sum(dd.bytes)/(1024*1024),2) tot_grootte_mb from sys.dba_data_files dd group by dd.tablespace_name) d where d.tablespace_name=f.tablespace_name order by 1;

 

你可能感兴趣的:(oracle)