oracle分区数据错乱,oracle分区问题:更改分区键值列的数据,导致ORA-14402错误

最初由 xzh2000 发布

[B]alter table xxx enable row_movement; [/B]

ok 问题解决了

from asktom:

It is possible to update a partition key in all releases -- what is not possible

to do prior to 8i is to update the partition key in such a fashion as to cause

it to move from partition to partition.  For example:

ops$tkyte@8.0> CREATE TABLE partitioned

2  ( x int,

3    y int,

4    z DATE

5  )

6  PARTITION BY RANGE (z)

7  (

8  PARTITION part_1 VALUES LESS

THAN(to_date('01-jan-1995','dd-mon-yyyy')),

9  PARTITION part_2 VALUES LESS

THAN(to_date('01-jan-1996','dd-mon-yyyy'))

10  )

11  /

Table created.

ops$tkyte@8.0>

ops$tkyte@8.0> insert into partitioned values

2  ( 1, 1, to_date('01-jan-1994','dd-mon-yyyy') );

1 row created.

ops$tkyte@8.0>

ops$tkyte@8.0> insert into partitioned values

2  ( 2, 1, to_date('01-mar-1995','dd-mon-yyyy') );

1 row created.

ops$tkyte@8.0>

ops$tkyte@8.0> commit;

Commit complete.

ops$tkyte@8.0>

ops$tkyte@8.0> update partitioned set

2           z = to_date('01-jan-1993')

where z = to_date('01-jan-1994')

3  /

1 row updated.

That shows we CAN update a partition key in 8.0

ops$tkyte@8.0> rollback;

Rollback complete.

ops$tkyte@8.0>

ops$tkyte@8.0> update partitioned set

2  z = decode( x, 1, to_date('01-mar-1995','dd-mon-yyyy'),

3              2, to_date('01-jan-1994','dd-mon-yyyy') )

4  /

update partitioned set

*

ERROR at line 1:

ORA-14402: updating partition key column would cause a partition change

But we cannot have it migrate.  Now, in Oracle8i, release 8.1 we can:

ops$tkyte@8i> CREATE TABLE partitioned

2  ( x int,

3    y int,

4    z DATE

5  )

6  PARTITION BY RANGE (z)

7  (

8  PARTITION part_1 VALUES LESS

THAN(to_date('01-jan-1995','dd-mon-yyyy')),

9  PARTITION part_2 VALUES LESS

THAN(to_date('01-jan-1996','dd-mon-yyyy'))

10  )

11  ENABLE ROW MOVEMENT

12  /

Table created.

Enable row movement will allow us to update a partition key and have it move

from partition to partition

ops$tkyte@8i>

ops$tkyte@8i> insert into partitioned values

2  ( 1, 1, to_date('01-jan-1994','dd-mon-yyyy') );

1 row created.

ops$tkyte@8i>

ops$tkyte@8i> insert into partitioned values

2  ( 2, 1, to_date('01-mar-1995','dd-mon-yyyy') );

1 row created.

ops$tkyte@8i>

ops$tkyte@8i> commit;

Commit complete.

ops$tkyte@8i>

ops$tkyte@8i> select rowid, a.* from partitioned a;

ROWID                       X          Y Z

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

AAAWBlAADAAAIfKAAA          1          1 01-JAN-94

AAAWBmAADAAAIgKAAA          2          1 01-MAR-95

ops$tkyte@8i> update partitioned set

2  z = decode( x, 1, to_date('01-mar-1995','dd-mon-yyyy'),

3              2, to_date('01-jan-1994','dd-mon-yyyy') )

4  /

2 rows updated.

ops$tkyte@8i> select rowid, a.* from partitioned a;

ROWID                       X          Y Z

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

AAAWBlAADAAAIfKAAB          2          1 01-JAN-94

AAAWBmAADAAAIgKAAB          1          1 01-MAR-95

ops$tkyte@8i> commit;

Commit complete.

but -- notice the side effect -- the rows ROWID changed, one of 2 cases in

Oracle8i release 8.1 whereby for the first time a rowid of a row will change

(index organized tables are the other case -- if you update the primary key)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值