您好,登錄后才能下訂單哦!
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
解決方案:
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",共同學習,共同成長!!!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。