暂无图片
暂无图片
暂无图片
暂无图片
1
暂无图片

Oracle在线收缩表——shrink space

原创 一年级小学生 2020-12-08
2052

表的年限比较久,水位线特别高,通过shrink 方式在线回收(生产要在空闲时操作)

–统计需要收缩表的信息(手工统计是为了下面查询水位线更准确)
SQL> exec dbms_stats.gather_table_stats(ownname=>‘USERNAME’,tabname=>‘TABLENAME’,estimate_percent=>10,method_opt=>‘for all indexed columns’,cascade=>TRUE);

–查询表得水位线 blocks是表的水位线
SQL> select num_rows,blocks from user_tables where table_name=‘TABLENAME’;

–开启表的行移动
SQL> alter table TABLENAME enable row movement;

–开始收缩表(如果数据量非常大需要执行很长时间)
SQL> alter table tablename shrink space;

–重新收集收缩表的信息
SQL> exec dbms_stats.gather_table_stats(ownname=>‘USERNAME’,tabname=>‘TABLENAME’,estimate_percent=>10,method_opt=>‘for all indexed columns’,cascade=>TRUE);

–查询收缩过表的水位线
SQL> select num_rows,blocks from user_tables where table_name=‘TABLENAME’;

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
1人已赞赏
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论

杜伟
暂无图片
1年前
评论
暂无图片 0
alter table TABLENAME disable row movement;关闭下行移动
1年前
暂无图片 点赞
评论