oracle查詢表空間大小以及每個表所佔空間的大小

2021-08-10 20:04:47 字數 1250 閱讀 1298

最近維護的專案遇到了oracle的效能的問題,需要查詢一下oracle資料庫表空間的大小以及每個表所佔空間的大小,在網上搜尋了一些查詢語句,在此記錄一下:

1、查詢資料庫中所有的表空間以及表空間所佔空間的大小,直接執行語句就可以了:

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

2、檢視表空間物理檔案的名稱及大小   

select tablespace_name, file_id, file_name,   

round(bytes/(1024*1024),0) total_space   

from dba_data_files   

order by tablespace_name; 

3、查詢所有表空間以及每個表空間的大小,已用空間,剩餘空間,使用率和空閒率,直接執行語句就可以了:

select a.tablespace_name, total, free, total-free as used, substr(free/total * 100, 1, 5) as "free%", substr((total - free)/total * 100, 1, 5) as "used%" from 

(select tablespace_name, sum(bytes)/1024/1024 as total from dba_data_files group by tablespace_name) a, 

(select tablespace_name, sum(bytes)/1024/1024 as free from dba_free_space group by tablespace_name) b

where a.tablespace_name = b.tablespace_name

order by a.tablespace_name;

4、查詢某個具體的表所佔空間的大小,把「table_name」換成具體要查詢的表的名稱就可以了:

select t.segment_name, t.segment_type, sum(t.bytes / 1024 / 1024) "占用空間(m)"

from dba_segments t

where t.segment_type='table'

and t.segment_name='table_name'

group by owner, t.segment_name, t.segment_type;

oracle查詢表空間大小以及每個表所佔空間的大小

1 查詢資料庫中所有的表空間以及表空間所佔空間的大小,直接執行語句就可以了 select tablespace name,sum bytes 1024 1024 from dba data files group by tablespace name 2 檢視表空間物理檔案的名稱及大小 select...

Oracle查詢表空間與表大小

資料表的大小由段和區組成 當前使用者下的可以使用下面sql分別顯示段和區資訊 select us.segment name,us.bytes from user segments us order by us.bytes desc select from user extents ue order ...

ORACLE查詢每個表占用空間大小

select select sum bytes from dba segments where owner testbar and segment type table and segment name table name from user tables 錯誤的,對於oracle而言,雙引號 要...