日期:2014-05-16  浏览次数:20731 次

查看Oracle数据库表空间大小(空闲、已使用),是否要增加表空间的数据文件


--查看每个表空间的大小
Select t.bytes/1024/1024/1024 bytes,t.* From Dba_Segments t where Tablespace_Name='CTBS_STAT' order by? t.bytes desc ;

?


--单位 MB
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? ;

--单位 GB

select?? a.tablespace_name,a.bytes/1024/1024/1024 "Sum GB",(a.bytes-b.bytes)/1024/1024/1024?? "used GB",b.bytes/1024/1024/1024 "free GB",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? ;

?

?

?

?

?

?

?

?

?

?

http://suan2046.iteye.com/blog/379539

?

?

?

?

?Oracle10g10.2.0.1.0
标题:查看Oracle数据库表空间大小,是否需要增加表空间的数据文件

?? 在数据库管理中,磁盘空间不足是DBA都会遇到的问题,问题比较常见。

?

--1查看表空间已经使用的百分比

Sql代码 复制代码?收藏代码
  1. 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"??
  2. from??
  3. (select?tablespace_name,sum(bytes)?bytes?from?dba_data_files?group?by?tablespace_name)???a, ??
  4. (select?tablespace_name,sum(bytes)?bytes,max(bytes)?largest?from?dba_free_space?group?by?tablespace_name)???b ??
  5. where???a.tablespace_name=b.tablespace_name ??
  6. order???by???((a.bytes-b.bytes)/a.bytes)???desc??
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) byte