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