[Oracle] - 查看数据库中每个表占用空间大小,及进行表压缩

查询用户创建的表

1
2
select * from user_tab_comments; -- 查询本用户的表,视图等。
select * from user_col_comments; -- 查询本用户的表的列名和注释。

 

查询所有表大小

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

 

查询用户创建的表大小

1
2
3
4
5
6
7
8
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

posted @   jinzesudawei  阅读(8971)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
阅读排行:
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
点击右上角即可分享
微信分享提示