Chinaunix首页 | 论坛 | 博客
  • 博客访问: 774456
  • 博文数量: 185
  • 博客积分: 7434
  • 博客等级: 少将
  • 技术积分: 2325
  • 用 户 组: 普通用户
  • 注册时间: 2005-12-29 14:01
文章分类

全部博文(185)

文章存档

2013年(1)

2012年(2)

2011年(17)

2010年(25)

2009年(36)

2008年(104)

分类: Oracle

2008-07-21 14:36:10

ORA-22856 Oracle 9i 压缩表添加字段报错的处理方法
    在oracle 9i版本中,如果表是compress,在添加字段时会报ORA-22856: cannot add columns to object tables错误,这是一个BUG(在10G及以上版本中不存在本文所述的问题),用以下方法可以绕过:
1.alter table <表名> nocompress
2.alter table <表名> move
3.alter table add column(添加字段)
注意:
1.不用直接用alter table <表名> move nocompress,一定要先指定nocompress,然后move,不然加字段还是出错
2.如果表有索引,还得rebuild一下索引
3.如要恢复compress属性,就在加完字段后,再次指定compress属性,再次move即可
4.在10G及以上版本中不存在以上问题

实验记录:
SQL> create table t3(a number(2),b number(2)) compress;

Table created.

SQL> insert into t3 values (1,1);

1 row created.

SQL> /

1 row created.

SQL> /

1 row created.

SQL> /

1 row created.

SQL> /

1 row created.

SQL> commit;

SQL> alter table t3 add (c number(2));
alter table t3 add (c number(2))
                    *
ERROR at line 1:
ORA-22856: cannot add columns to object tables


SQL>
SQL> alter table t3 move nocompress;

Table altered.

SQL> alter table t3 add (c number(2));
alter table t3 add (c number(2))
                    *
ERROR at line 1:
ORA-22856: cannot add columns to object tables

SQL> alter table t3 nocompress;  

Table altered.

SQL> alter table t3 move;

Table altered.

SQL> alter table t3 add (c number(2));

Table altered.

作者:george.ma Blog:http://blog.chinaunix.net/u/12521/

阅读(1631) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~