oracle 收高水位,oracle 回收高水位线

select  round((1-a.used/b.num_total)*100,0)  percent from

(SELECT COUNT (DISTINCT SUBSTR(rowid,1,15)) Used FROM 表名) a,

(select blocks num_total from dba_tables where table_name='表名' and wner='用户名') b;

通过dba_tables里的blocks字段和有数据的字段做对比,在用1减,求出没有数据的块的百分比(一般超过20%就需要回收了)从而判定是否需要回收高水位线

SQL> alter table test_shrik enable row movement ;

SQL> alter table test_shrik shrink space ;

SQL> select t.table_name,BLOCKS,EMPTY_BLOCKS,NUM_ROWS

from user_tables t

where table_name = upper('test_shrik');

exec dbms_stats.gather_table_stats('sys','test_shrik');

SQL> select t.table_name,BLOCKS,EMPTY_BLOCKS,NUM_ROWS

from user_tables t

where table_name = upper('test_shrik');

高水位线已经下降了

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30345407/viewspace-2149483/,如需转载,请注明出处,否则将追究法律责任。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值