oracle查看表空间的几个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"
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

“Sum MB”表示表空间所有的数据文件总共在操作系统占用磁盘空间的大小
比如:test表空间有2个数据文件,datafile1为300MB,datafile2为400MB,那么test表空间的“Sum MB”就是700MB
“userd MB”表示表空间已经使用了多少
“free MB”表示表空间剩余多少
“percent_user”表示已经使用的百分比

2.可以查看PAT表空间总共有几个数据文件,每个数据文件是否自动扩展,可以自动扩展的最大值。

select   file_name,tablespace_name,bytes/1024/1024 "bytes MB",maxbytes/1024/1024 "maxbytes MB"  
from dba_data_files where tablespace_name='PAT';

3.删除表空间数据文件

alter   tablespace   PAT  
drop    datafile '/oracle/oms/oradata/mlog/PAT.dbf'  

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM