重庆思庄Oracle、Redhat认证学习论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1914|回复: 0
打印 上一主题 下一主题

[Oracle] 在为表添加了列后执行ALTER TABLE SHRINK SPACE 提示ORA-8102

[复制链接]
跳转到指定楼层
楼主
发表于 2021-12-19 18:42:17 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
APPLIES TO:Oracle Database - Standard Edition - Version 12.1.0.1 to 19.7.0.0.0 [Release 12.1 to 19]
Information in this document applies to any platform.
SYMPTOMS
ALTER TABLE SHRINK SPACE command returns ORA-8102 after adding column.

SQL> alter table <TABLE_NAME> shrink space;
alter table <TABLE_NAME> shrink space
*
ERROR at line 1:
ORA-08102: index key not found, obj# NNNNN, file N, block NNNNN (2)


CHANGES
After adding a column with add column optimization and creating a new index on the column.
"add column optimization" is enabled by default when adding a column with DEFAULT value.
alter table <TABLE_NAME> add <COLUMN_NAME_NEW> number default 10 not null;
create index <INDEX_NAME_NEW> on <TABLE_NAME> ( <COLUMN_NAME1>, <COLUMN_NAME_NEW>);

CAUSE
This problem has been investigated under Bug:22473983.
SOLUTION
After the error:
Drop a index on the table for the added column. And rerun ALTER TABLE SHRINK SPACE command.
After completion the shrink table, recreate the index as you need.
drop index <INDEX_NAME_NEW>;


Before the adding columns:
Before adding columns, set parameter "_add_col_optim_enabled" = false.
alter session set "_add_col_optim_enabled" = false;
alter table <TABLE_NAME> add <COLUMN_NAME_NEW> number default 10;
create index <INDEX_NAME_NEW> on <TABLE_NAME> ( <COLUMN_NAME1>, <COLUMN_NAME_NEW>);


分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 支持支持 反对反对
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|手机版|小黑屋|重庆思庄Oracle、Redhat认证学习论坛 ( 渝ICP备12004239号-4 )

GMT+8, 2024-11-29 21:09 , Processed in 0.090591 second(s), 20 queries .

重庆思庄学习中心论坛-重庆思庄科技有限公司论坛

© 2001-2020

快速回复 返回顶部 返回列表