當前位置:
首頁 >
ORA-14402
發布時間:2024/8/26
44
豆豆
默認情況下,oracle的分區表對于分區字段是不允許進行update操作的,如果有對分區字段行進update,就會報錯——ORA-14402: 更新分區關鍵字列將導致分區的更改。但是可以通過打開表的row movement屬性來允許對分區字段的update操作。
例:創建分區表test_part進行實驗
create table TEST_PART
(
??A1 NUMBERnot null,
??A2 DATE? ?? ?not null,
??A3 VARCHAR2(6) not null,
??A4 DATE not null,
??A5 NUMBER not null,
)
partition by range (A1)
(
??partition P1 values less than (1000),
??partition P2 values less than (2000),
??partition P3 values less than (3000),
??partition P4 values less than (4000),
??partition P5 values less than (5000),
??partition P6 values less than (MAXVALUE)
);
插入如下的數據
SQL> select * from test_part;
? ?? ???A1 A2? ?? ?? ? A3? ???A4? ?? ?? ?? ?? ?? ?A5
---------- ----------- ------ ----------- ----------
? ?? ? 123 2006-06-30??123456 2006-06-30? ?? ?? ?123
? ?? ? 456 2006-06-30??asdfgh 2006-06-30? ?? ?? ?456
? ?? ?? ?1 2006-06-30??234123 2006-06-30? ?? ?? ???1
? ?? ?? ?2 2006-06-30??234234 2006-06-30? ?? ?? ???2
? ?? ?1234 2006-06-30??456789 2006-06-30? ?? ???1234
? ?? ?1111 2006-06-30??ewrqwe 2006-06-30? ?? ???1111
? ?? ?2222 2006-06-30??fdafda 2006-06-30? ?? ???2222
? ?? ?3333 2006-06-30??342342 2006-06-30? ?? ???3333
? ?? ?5678 2006-06-30??qwerty 2006-06-30? ?? ???5678
9 rows selected
分區P1、P2的數據分別為:
SQL> select rowid,t.* from test_part partition(p1) t;
ROWID? ?? ?? ?? ?? ?? ?? ? A1 A2? ?? ?? ? A3? ???A4? ?? ?? ?? ?? ?? ?A5
------------------ ---------- ----------- ------ ----------- ----------
AAAGLoAAGAAAtsEAAB? ?? ???456 2006-06-30??asdfgh 2006-06-30? ?? ?? ?456
AAAGLoAAGAAAtsEAAC? ?? ?? ? 1 2006-06-30??234123 2006-06-30? ?? ?? ???1
AAAGLoAAGAAAtsEAAD? ?? ?? ? 2 2006-06-30??234234 2006-06-30? ?? ?? ???2
AAAGLoAAGAAAtsEAAE? ?? ???123 2006-06-30??123456 2006-06-30? ?? ?? ?123
SQL> select rowid,t.* from test_part partition(p2) t;
ROWID? ?? ?? ?? ?? ?? ?? ? A1 A2? ?? ?? ? A3? ???A4? ?? ?? ?? ?? ?? ?A5
------------------ ---------- ----------- ------ ----------- ----------
AAAGLwAAGAAA+8MAAC? ?? ? 1234 2006-06-30??456789 2006-06-30? ?? ???1234
AAAGLwAAGAAA+8MAAD? ?? ? 1111 2006-06-30??ewrqwe 2006-06-30? ?? ???1111
直接update提示錯誤
SQL> update test_part set a1=1123 where a1=123;
update test_part set a1=1123 where a1=123
ORA-14402: 更新分區關鍵字列將導致分區的更改
打開row movement屬性
SQL> alter table test_part enable row movement;
Table altered
再次執行update操作
SQL> update test_part set a1=1123 where a1=123;
1 row updated
執行是成功的并遷移到分區P2上了,且這時候rowid也發生了變化
SQL> select rowid,t.* from test_part partition(p2) t;
ROWID? ?? ?? ?? ?? ?? ?? ? A1 A2? ?? ?? ? A3? ???A4? ?? ?? ?? ?? ?? ?A5
------------------ ---------- ----------- ------ ----------- ----------
AAAGLwAAGAAA+8MAAC? ?? ? 1234 2006-06-30??456789 2006-06-30? ?? ???1234
AAAGLwAAGAAA+8MAAD? ?? ? 1111 2006-06-30??ewrqwe 2006-06-30? ?? ???1111
AAAGLwAAGAAA+8PAAB? ?? ? 1123 2006-06-30??123456 2006-06-30? ?? ?? ?123
SQL>?
enable row movement可以允許數據段的壓縮、update分區字段的數據(跨分區的)
但是,也是有限制性的:對于普通表(heap-organized)行遷移后rowid會發生變化,對于索引表(index-organized)rowid雖然依然有效,但是其實際對應的物理構成是錯誤的。 體驗新版博客
例:創建分區表test_part進行實驗
create table TEST_PART
(
??A1 NUMBERnot null,
??A2 DATE? ?? ?not null,
??A3 VARCHAR2(6) not null,
??A4 DATE not null,
??A5 NUMBER not null,
)
partition by range (A1)
(
??partition P1 values less than (1000),
??partition P2 values less than (2000),
??partition P3 values less than (3000),
??partition P4 values less than (4000),
??partition P5 values less than (5000),
??partition P6 values less than (MAXVALUE)
);
插入如下的數據
SQL> select * from test_part;
? ?? ???A1 A2? ?? ?? ? A3? ???A4? ?? ?? ?? ?? ?? ?A5
---------- ----------- ------ ----------- ----------
? ?? ? 123 2006-06-30??123456 2006-06-30? ?? ?? ?123
? ?? ? 456 2006-06-30??asdfgh 2006-06-30? ?? ?? ?456
? ?? ?? ?1 2006-06-30??234123 2006-06-30? ?? ?? ???1
? ?? ?? ?2 2006-06-30??234234 2006-06-30? ?? ?? ???2
? ?? ?1234 2006-06-30??456789 2006-06-30? ?? ???1234
? ?? ?1111 2006-06-30??ewrqwe 2006-06-30? ?? ???1111
? ?? ?2222 2006-06-30??fdafda 2006-06-30? ?? ???2222
? ?? ?3333 2006-06-30??342342 2006-06-30? ?? ???3333
? ?? ?5678 2006-06-30??qwerty 2006-06-30? ?? ???5678
9 rows selected
分區P1、P2的數據分別為:
SQL> select rowid,t.* from test_part partition(p1) t;
ROWID? ?? ?? ?? ?? ?? ?? ? A1 A2? ?? ?? ? A3? ???A4? ?? ?? ?? ?? ?? ?A5
------------------ ---------- ----------- ------ ----------- ----------
AAAGLoAAGAAAtsEAAB? ?? ???456 2006-06-30??asdfgh 2006-06-30? ?? ?? ?456
AAAGLoAAGAAAtsEAAC? ?? ?? ? 1 2006-06-30??234123 2006-06-30? ?? ?? ???1
AAAGLoAAGAAAtsEAAD? ?? ?? ? 2 2006-06-30??234234 2006-06-30? ?? ?? ???2
AAAGLoAAGAAAtsEAAE? ?? ???123 2006-06-30??123456 2006-06-30? ?? ?? ?123
SQL> select rowid,t.* from test_part partition(p2) t;
ROWID? ?? ?? ?? ?? ?? ?? ? A1 A2? ?? ?? ? A3? ???A4? ?? ?? ?? ?? ?? ?A5
------------------ ---------- ----------- ------ ----------- ----------
AAAGLwAAGAAA+8MAAC? ?? ? 1234 2006-06-30??456789 2006-06-30? ?? ???1234
AAAGLwAAGAAA+8MAAD? ?? ? 1111 2006-06-30??ewrqwe 2006-06-30? ?? ???1111
直接update提示錯誤
SQL> update test_part set a1=1123 where a1=123;
update test_part set a1=1123 where a1=123
ORA-14402: 更新分區關鍵字列將導致分區的更改
打開row movement屬性
SQL> alter table test_part enable row movement;
Table altered
再次執行update操作
SQL> update test_part set a1=1123 where a1=123;
1 row updated
執行是成功的并遷移到分區P2上了,且這時候rowid也發生了變化
SQL> select rowid,t.* from test_part partition(p2) t;
ROWID? ?? ?? ?? ?? ?? ?? ? A1 A2? ?? ?? ? A3? ???A4? ?? ?? ?? ?? ?? ?A5
------------------ ---------- ----------- ------ ----------- ----------
AAAGLwAAGAAA+8MAAC? ?? ? 1234 2006-06-30??456789 2006-06-30? ?? ???1234
AAAGLwAAGAAA+8MAAD? ?? ? 1111 2006-06-30??ewrqwe 2006-06-30? ?? ???1111
AAAGLwAAGAAA+8PAAB? ?? ? 1123 2006-06-30??123456 2006-06-30? ?? ?? ?123
SQL>?
enable row movement可以允許數據段的壓縮、update分區字段的數據(跨分區的)
但是,也是有限制性的:對于普通表(heap-organized)行遷移后rowid會發生變化,對于索引表(index-organized)rowid雖然依然有效,但是其實際對應的物理構成是錯誤的。 體驗新版博客
總結
- 上一篇: 消费提示:警惕近期淘宝上大量超低价白菜包
- 下一篇: 利用dbms_metadata.get_