Oracle—deallocate unused释放高水位空间(二)


deallocate unused :仅适用于释放HWM高水位以上的空间,而无法释放高水位以下的空间;比如对表预分配的空间
使用说明和方法,官方文档有说明,如下:Use the deallocate_unused_clause to explicitly deallocate unused space at the end ofa database object segment and make the space available for other segments in thetablespace.You can deallocate unused space using the following statements:■ ALTER CLUSTER (see ALTER CLUSTER on page 10-5)■ ALTER INDEX: to deallocate unused space from the index, an index partition, or anindex subpartition (see ALTER INDEX on page 10-78)■ ALTER MATERIALIZED VIEW: to deallocate unused space from the overflow segmentof an index-organized materialized view (see ALTER MATERIALIZED VIEW onpage 11-3)■ ALTER TABLE: to deallocate unus免费云主机域名ed space from the table, a table partition, a tablesubpartition, the mapping table of an index-organized table, the overflow segmentof an index-organized table, or a LOB storage segment (see ALTER TABLE onpage 12-2)
一、测试环境:Oracle11.2.0.4使用admin用户在test表空间新建一张测试分区表,并提前对子分区预分配一些空间,然后插入少量的数据,最后使用:alter table …..deallocate unused;来释放未使用的空间
二、开始测试①:查看测试环境表空间使用情况:②:创建测试分区表:test_emp ③:给pt_1分区表预分配10G的空间:④:收集该分区表的统计信息,并查看该表的block块占用情况—从上面可以看出,test_emp分区表的大小是10G,而占用的blocks有1315840个;

⑤:向分区表插入一些数据,并查看该表的大小
–注意:从上面可以看出,该表的大小是10G,但是该表占用blocks只有46个,显然 有很多空间没有被使用,
⑥:释放未被使用的空间(我对该操作过了10046事件,在实际操作中只需执行:alter table test_emp modify partition pt_1 deallocate unused; )
⑦:验证空间是否被释放:

从上面可以看出,该表的大小变成了16M,而blocks也有1024个;表未被使用的空间已经释放,而且表空间可用大小也已经变大:

相关推荐: PostgreSQL中与AUTOVACUUM IO相关的参数是什么

本篇内容介绍了“PostgreSQL中与AUTOVACUUM IO相关的参数是什么”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!PG的MVCC要求“过期”的数据…

免责声明:本站发布的图片视频文字,以转载和分享为主,文章观点不代表本站立场,本站不承担相关法律责任;如果涉及侵权请联系邮箱:360163164@qq.com举报,并提供相关证据,经查实将立刻删除涉嫌侵权内容。

(0)
打赏 微信扫一扫 微信扫一扫
上一篇 01/21 11:42
下一篇 01/21 13:29