[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

转载于:https://www.cnblogs.com/jinzesudawei/p/10715246.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值