[Oracle] - 查看數據庫中每個表占用空間大小,及進行表壓縮


查詢用戶創建的表

select * from user_tab_comments; -- 查詢本用戶的表,視圖等。
select * from user_col_comments; -- 查詢本用戶的表的列名和注釋。

 

查詢所有表大小

select Segment_Name, Sum(bytes) / 1024 / 1024 / 1024 "size(DB)"
  From User_Extents
 Group By Segment_Name
 order by "size(DB)" desc, Segment_Name

 

查詢用戶創建的表大小

select UT.table_name, x.TABLE_SIZE
  from user_tab_comments ut,
       (select Segment_Name, Sum(bytes) / 1024 / 1024 / 1024 as "TABLE_SIZE"
          From User_Extents
         Group By Segment_Name) x
 where ut.table_type = 'TABLE'
   and ut.table_name = x.Segment_Name(+)
 order by x.TABLE_SIZE desc

 

范例

 

關於Oracle表壓縮

如果是一個已經存在的表要進行壓縮也很簡單:

alter table table1 move compress;

如果是一個分區表的話會更加靈活,只需要壓縮你想要壓縮的表空間就可以了:

alter table tables1 move partition part_1 compress;

 

壓縮失敗

ora-00439:是因為未啟用功能partitioning

參數檢查:

select * from v$option

Partitioning false

解決方式:

Partitioning true

 

參考資料

https://blog.csdn.net/silenceray/article/details/78878948
https://blog.csdn.net/hahalzb/article/details/6399856
https://www.cnblogs.com/seasonzone/p/7206040.html
https://www.cnblogs.com/zhangmen/p/4731606.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM