ORA-39726:unsupported add/drop column operation on compressed tables

发布时间:2020-08-15 09:41:32 作者:chenoracle
来源:ITPUB博客 阅读:237

ORA-39726:

 unsupported add/drop column operation on compressed tables

 

问题现象 :

Basic compression 下,增加字段时不能指定default ,否则报错 ORA-39726

问题重现:
SQL> conn chenjch/a

SQL> create table t1(id number(10) not null) compress;

SQL> insert into t1 values(1);

SQL> commit;

SQL> ALTER TABLE t1 ADD UPDATE_TIME DATE DEFAULT SYSDATE NOT NULL ;

ALTER TABLE t1 ADD UPDATE_TIME DATE DEFAULT SYSDATE NOT NULL

                   *

ERROR at line 1:

ORA-39726: unsupported add/drop column operation on compressed tables

问题原因 :

https://docs.oracle.com/cd/E11882_01/server.112/e25494/tables.htm#ADMIN11630

  ORA-39726:unsupported add/drop column operation on compressed tables 

解决方案:

SQL> SELECT table_name, compression, compress_for FROM user_tables where table_name='T1';

TABLE_NAME COMPRESS COMPRESS_FOR

---------- -------- ------------------------------

T1         ENABLED   BASIC

 

--- 去掉 default 后可以正常添加列,但是很多情况下业务逻辑是不允许的;

ALTER TABLE t1 ADD UPDATE_TIME DATE;

--- 将表压缩级别 basic 改成 oltp 后可以正常添加字段;
--- 对现有的数据不压缩,对以后产生的数据生效,数据量越大,速度越慢,测试 1 亿条数据,耗时 30 秒;

SQL> alter table t1 compress for oltp;    
---- 对现有的和以后的数据都生效,数据量越大,速度越慢,并且会产生排它锁,生产环境慎用;

sql> Alter table t1 move compress for oltp;  

SQL>  SELECT table_name, compression, compress_for FROM user_tables where table_name='T1';

TABLE_NAME COMPRESS COMPRESS_FOR

---------- -------- ------------------------------

T1         ENABLED   ADVANCED

 

SQL> ALTER TABLE t1 ADD UPDATE_TIME DATE DEFAULT SYSDATE NOT NULL ;

Table altered.

--- 字段添加成功后也可以在改回 basic;

SQL> alter table t1 compress;

Table altered.

 

SQL> SELECT table_name, compression, compress_for FROM user_tables where table_name='T1';

TABLE_NAME COMPRESS COMPRESS_FOR

---------- -------- ------------------------------

T1         ENABLED  BASIC

 

同理,删除字段也会有这个问题

SQL> ALTER TABLE t1 drop column  UPDATE_TIME;

ALTER TABLE t1 drop column  UPDATE_TIME

                            *

ERROR at line 1:

ORA-39726: unsupported add/drop column operation on compressed tables

SQL> ALTER TABLE t1 SET UNUSED COLUMN UPDATE_TIME;

Table altered.

SQL> ALTER TABLE t1 DROP UNUSED COLUMNS;

ALTER TABLE t1 DROP UNUSED COLUMNS

*

ERROR at line 1:

ORA-39726: unsupported add/drop column operation on compressed tables

 

SQL> alter table t1 compress for oltp;

Table altered.


SQL> ALTER TABLE t1 DROP UNUSED COLUMNS;

Table altered.

SQL> alter table t1 compress;

Table altered.

  欢迎关注我的微信公众号"IT小Chen",共同学习,共同成长!!!

ORA-39726:unsupported add/drop column operation on compressed tables

ORA-39726:unsupported add/drop column operation on compressed tables


 

 

 

 

推荐阅读:
  1. python3中hex函数的使用方法
  2. Python文件中IO指的是什么意思

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

ora-39726 add compressed

上一篇:软件测试实践之路:学习资料倾情奉献

下一篇:小心!异常断电对SSD的危害原来这么大

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》