查詢表空間及已使用情況的SQL語句

2022-09-16 12:27:09 字數 2328 閱讀 7622

語句一:

select  

f.tablespace_name tablespace_name,

round((d.sumbytes / 1024 / 1024 / 1024), 2) total_g,

round(f.sumbytes / 1024 / 1024 / 1024, 2) free_g,

round((d.sumbytes - f.sumbytes) / 1024 / 1024 / 1024, 2) used_g,

round((d.sumbytes - f.sumbytes) * 100 / d.sumbytes, 2) used_percent

from

(select tablespace_name, sum(bytes) sumbytes from dba_free_space group by tablespace_name) f,

(select tablespace_name, sum(bytes) sumbytes from dba_data_files group by tablespace_name) d

where f.tablespace_name = d.tablespace_name

order by used_percent desc,d.tablespace_name;

語句二:

select a.tablespace_name, 

round(a.bytes/1024/1024/1024,2) total, 

round(b.bytes/1024/1024/1024,2) used, 

round(c.bytes/1024/1024/1024,2) free, 

round((b.bytes * 100) / a.bytes,2) "% used ", 

round((c.bytes * 100) / a.bytes,2) "% free " 

from sys.sm$ts_**ail a, sys.sm$ts_used b, sys.sm$ts_free c 

where a.tablespace_name = b.tablespace_name 

and a.tablespace_name = c.tablespace_name;

語句一:使用到的檢視有

語句二:使用到的檢視

檢視:sys.sm$ts_**ail是由dba_data_files而來的

檢視:sys.sm$ts_used是由dba_segments而來的

檢視:sys.sm$ts_free是由dba_free_space而來的

select * from dba_tablespaces -- 記錄各個表空間的詳細資訊  

select * from dba_tablespace_usage_metrics -- 記錄各個表空間的使用狀況  

select * from dba_data_files -- 記錄各個資料檔案的詳細資訊  

select * from dba_segments -- 記錄各個段的詳細資訊,與 dba_tables,dba_indexes,dba_lobs,dba_part_tables,dba_part_indexes,dba_part_lobs,dba_objects 搭配使用  

select * from dba_lobs    --blob 欄位所對應的欄位名稱  

select * from dba_indexes -- 分割槽索引需要通過 dba_indexs 來找到對應的表名  

select * from dba_extents -- 記錄各個區間物件的詳細資訊

查詢表空間使用情況

select owner,tablespace name,segment name,segment type,sum bytes 1024 1024 sums from dba extents where owner nbcheck and segment type table group by o...

Oracle表空間檢視sql使用情況

dba在日常工作中,最重要的一點就是檢視表空間的使用情況,去了解是否有表空間滿了的情況出現。具體方法和步驟如下所示 第一步 開啟plsql 第二步 新建乙個sql視窗 第三步 輸入 select a.tablespace name tablespace n程式設計客棧ame nvl ceil 1 b...

查詢oracle表空間使用情況

1.查詢表空間所在物理路徑及使用情況.select b.file id 檔案id,b.tablespace name 表空間,b.file name 物理檔名,b.bytes 總位元組數,b.bytes sum nvl a.bytes,0 已使用,sum nvl a.bytes,0 剩餘,sum n...