Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Table compression and alter table statement

509719Apr 3 2007 — edited Apr 3 2007

Friends

I am trying to add columns to a table which is compressed. Since Oracle treats compressed tables as Object tables, I cannot add columns directly so I tried to uncompress table first and then add columns. This doesnt seems to work.

What could be issue.

Thanks
Vishal V.

Script to test is here and results are below.

-- Test1 => add columns to uncompressed table -> Success
DROP TABLE TAB_COMP;
CREATE TABLE TAB_COMP(ID NUMBER) NOCOMPRESS;
ALTER TABLE TAB_COMP ADD (NAME VARCHAR2(10));

-- Test2 =. try adding columns to compressed tables, uncompress it and then try again -> Fails
DROP TABLE TAB_COMP;
CREATE TABLE TAB_COMP(ID NUMBER) COMPRESS;
ALTER TABLE TAB_COMP ADD (NAME VARCHAR2(10));
ALTER TABLE TAB_COMP move NOCOMPRESS;
ALTER TABLE TAB_COMP ADD (NAME VARCHAR2(10));
SQL> -- Test1 => add columns to uncompressed table -> Success
SQL> DROP TABLE TAB_COMP;

Table dropped.

SQL> CREATE TABLE TAB_COMP(ID NUMBER) NOCOMPRESS;

Table created.

SQL> ALTER TABLE TAB_COMP ADD (NAME VARCHAR2(10));

Table altered.

SQL> 
SQL> -- Test2 =. try adding columns to compressed tables, uncompress it and then try again -> Fails
SQL> DROP TABLE TAB_COMP;

Table dropped.

SQL> CREATE TABLE TAB_COMP(ID NUMBER) COMPRESS;

Table created.

SQL> ALTER TABLE TAB_COMP ADD (NAME VARCHAR2(10));
ALTER TABLE TAB_COMP ADD (NAME VARCHAR2(10))
                          *
ERROR at line 1:
ORA-22856: cannot add columns to object tables


SQL> ALTER TABLE TAB_COMP move NOCOMPRESS;

Table altered.

SQL> ALTER TABLE TAB_COMP ADD (NAME VARCHAR2(10));
ALTER TABLE TAB_COMP ADD (NAME VARCHAR2(10))
                          *
ERROR at line 1:
ORA-22856: cannot add columns to object tables
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 1 2007
Added on Apr 3 2007
4 comments
670 views