oracle表空間及表大小檢視

2022-03-07 09:38:49 字數 871 閱讀 2467

oracle表空間及表大小檢視

今天看資料庫的表空間,感覺賽了很多東西,表空間檔案太大了。

找了下資料,先查詢表所佔空間大小,使用如下語句檢視:

sql**  

select segment_name, sum(bytes) / 1024 / 1024 mbytese  

from user_segments  

where segment_type = 'table'  

group by segment_name;   或者

sql**  

select segment_name,sum(bytes)/1024/1024 as sizeof from user_extents group by segment_name order by sizeof desc  

一般大資料量的刪全表資料時,使用truncate table

truncate table會釋放表空間。

delete table需要alter tablespace *** coalesce; 才有空間

truncate table沒有事務概念,執行完了就資料全清了。

truncate 會把 highwatermark 回歸至 0  當下一次再插入新記錄時就會快一些啦。

truncate table index也會刪掉不是指drop index ;

注意:刪除資料不能縮小表空間,只是可再利用的多了.

要實際縮小,讓作業系統可以利用,需要先把錶move tablespace

也可以在原來的tablespace上move一遍,再縮小tablespace就可以了.

例如:alter table your_table move tablespace yourtablespace;

oracle 表空間及表大小檢視

今天看資料庫的表空間,感覺賽了很多東西,表空間檔案太大了。找了下資料,先查詢表所佔空間大小,使用如下語句檢視 select segment name,sum bytes 1024 1024 mbytese from user segments where segment type table gro...

檢視oracle表空間大小

1.檢視所有表空間大小 sql select tablespace name,sum bytes 1024 1024 from dba data files group by tablespace name 2.已經使用的表空間大小 sql select tablespace name,sum by...

檢視oracle表空間大小

select upper f.tablespace name 表空間名 d.tot grootte mb 表空間大小 m d.tot grootte mb f.total bytes 已使用空間 m to char round d.tot grootte mb f.total bytes d.tot...