oracle如何释放数据库空间吗,Oracle 如何释放数据库空间

当需要释放数据库空间的时候,通常的方案会用有truncate、delete、drop/re-creating等处理。其中truncate 后会立即释放,并且不能回滚;但delete不能立即释放数据库空间,还会产生archive log。下面就简单介绍一下:

Truncate

如: Truncate table xxxx; 我们可以直接去查user_segments对应table的bytes就变小,数据库空间释放,并且不能回滚。用Truncate去删除记录比drop表再创建表效率更高。

Use the  TRUNCATE statement to remove all rows from a table or cluster. By default, Oracle Database also deallocates all space used by the removed rows except that specified by the  MINEXTENTS storage parameter and sets the  NEXT storage parameter to the size of the last extent removed from the segment by the truncation process.

Removing rows with the  TRUNCATE statement can be more efficient than dropping and re-creating a table. Dropping and re-creating a table invalidates dependent objects of the table, requires you to regrant object privileges on the table, and requires you to re-create the indexes, integrity constraints, and triggers on the table and respecify its storage parameters. Truncating has none of these effects.

Delete

Delete操作后,不能立即释放数据库空间,并且还会产生archive log(查看user_segments大小没有变化),需要做其他操作。如Oracle 10g, 11可以用下面操作来释放数据库空间。

alter table table_name shrink space cascade;

如果报ora-10636 row movement is not enabled,先执行下面语句:

alter table table_name enable row movement;

(由于是个人的一些理解,主要是总结一下,如有不对,欢迎指正)

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值