oracle 表收缩,Oracle 收缩表大小 Oracle Shrink Table

语法:

alter table shrink space [ | compact | cascade ];

alter table shrink space compcat;

收缩表,相当于把块中数据打结实了,但会保持 high water mark;

alter table shrink space;

收缩表,降低 high water mark;

alter table shrink space cascade;

收缩表,降低 high water mark,并且相关索引也要收缩一下下。

alter index idxname shrink space;

回缩索引

1:普通表

Sql脚本,改脚本会生成相应的语句

select'alter table '||table_name||' enable row movement;'||chr(10)||'alter table '||table_name||' shrink space;'||chr(10)from user_tables;

select'alter index '||index_name||' shrink space;'||chr(10)from user_indexes;

2:分区表的处理

进行shrink space时 发生ORA-10631错误.shrink space有一些限制.

在表上建有函数索引(包括全文索引)会失败。

Sql脚本,改脚本会生成相应的语句

select 'alter table '||table_name||' enable row movement;'||chr(10)||'alter table '||table_name||' shrink space;'||chr(10) from user_tables where ;

select 'alter index '||index_name||' shrink space;'||chr(10) from user_indexes where uniqueness='NONUNIQUE' ;

select 'alter table '||segment_name||' modify subpartition '||partition_name||' shrink space;'||chr(10) from user_segments where segment_type='TABLE SUBPARTITION' ';

示例

在Oracle中可以使用alter table table_name shrink space收缩表,使用shrink有两个前提条件:

1、表必须启用row movement

2、表段所在表空间的段空间管理(segment space management)必须为auto0b1331709591d260c1c78e86d0c51c18.png

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值