oracle压缩表(二)

上一篇 / 下一篇  2007-04-17 00:00:00 / 个人分类:Oracle技术

在低版本的oracle中,一旦对表进行了压缩,就不能添加删除字段了。但在10g下,可以对压缩表进行结构的变更。
看下面的例子:

SQL> select * from v$version;

BANNER
----------------------------------------------------------------
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
PL/SQL Release 9.2.0.1.0 - Production
CORE 9.2.0.1.0 Production

TNS for 32-bit Windows: Version 9.2.0.1.0 - Production
NLSRTL Version 9.2.0.1.0 - Production

SQL> create table tom(id number) compress;

Table created

SQL> insert /*+ append */ into tom select rownum from dba_objects;

6186 rows inserted

SQL> commit;

Commit complete

SQL> alter table tom nocompress;

Table altered

SQL> alter table tom move;

Table altered

SQL> alter table tom add(b number);

alter table tom add(b number)

ORA-22856: 无法在对象表中添加列

在9201中,无论怎么做无法对表进行添加删除列的操作。

在9204中,有了一点改进,虽然也不能用直接的方法对表结构进行修改,但可以通过曲折的步骤修改压缩表结构。

SQL> select * from v$version;

BANNER
----------------------------------------------------------------
Oracle9i Enterprise Edition Release 9.2.0.4.0 - 64bit Production
PL/SQL Release 9.2.0.4.0 - Production
CORE 9.2.0.3.0 Production
TNS for Linux: Version 9.2.0.4.0 - Production
NLSRTL Version 9.2.0.4.0 - Production

SQL> create table tom(id number) compress;

Table created.

SQL> insert /*+ append */ into tom select rownum from dba_objects;

30837 rows created.

SQL> commit;

Commit complete.

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


SQL> alter table tom nocompress;

Table altered.

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


SQL> alter table tom move;

Table altered.

SQL> alter table tom add(b number);

Table altered.

SQL> alter table tom compress;

Table altered.

SQL> alter table tom move;

Table altered.

归结一下:
1) alter table xxx nocompress;
2) alter xxx move;
3) alter table xxx
4) alter table xxx compress;
5) alter table xxx move
6) 最后,如果有索引的话不要忘了重建索引

在10g下,oracle显然修正了这个bug
SQL> select * from v$version;

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi
PL/SQL Release 10.2.0.3.0 - Production
CORE 10.2.0.3.0 Production
TNS for Solaris: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production


SQL> create table tom(id number) compress;

表已创建。

SQL> insert /*+ append */ into tom select rownum from dba_objects;

已创建51880行。

SQL> commit;

提交完成。

SQL> alter table tom add(b number);

表已更改。



TAG:

 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

日历

« 2008-08-22  
     12
3456789
10111213141516
17181920212223
24252627282930
31      

数据统计

  • 访问量: 9739
  • 日志数: 410
  • 建立时间: 2007-12-30
  • 更新时间: 2008-08-21

RSS订阅

Open Toolbar