分区表 行移动

oracle 

oracle 8.0中没有行移动功能,在这个版本中,必须先删除该行,再重新将其插入

测试环境oracle 11.2.0.3.0




-- Create table
create table GH_RANGE_EXAMPLE
(
  id         VARCHAR2(100),
  range_date DATE not null
)
partition by range (RANGE_DATE)
(
  partition RANGE_15 values less than (TO_DATE(' 2016-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    tablespace TS_ZYK_DATA
    pctfree 10
    initrans 1
    maxtrans 255
    storage
    (
      initial 8M
      next 1M
      minextents 1
      maxextents unlimited
    ),
  partition RANGE_16 values less than (TO_DATE(' 2017-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    tablespace TS_ZYK_DATA
    pctfree 10
    initrans 1
    maxtrans 255
    storage
    (
      initial 8M
      next 1M
      minextents 1
      maxextents unlimited
    ),
  partition RANGE_MAX values less than (MAXVALUE)
    tablespace TS_ZYK_DATA
    pctfree 10
    initrans 1
    maxtrans 255
);


SQL> select * from gh_range_example t;
ID                                                                               RANGE_DATE
-------------------------------------------------------------------------------- -----------
100                                                                              2015/6/16 1
100                                                                              2016/6/15 1


SQL> update gh_range_example t set t.id=t.id+1;
2 rows updated

SQL> select * from gh_range_example t;
ID                                                                               RANGE_DATE
-------------------------------------------------------------------------------- -----------
101                                                                              2015/6/16 1
101                                                                              2016/6/15 1



SQL> update gh_range_example t set t.range_date=trunc(sysdate) where t.range_date < trunc(sysdate)-10;
update gh_range_example t set t.range_date=trunc(sysdate) where t.range_date < trunc(sysdate)-10
ORA-14402: updating partition key column would cause a partition change


SQL> select rowid from gh_range_example t where t.range_date < trunc(sysdate)-10;
ROWID
--------------------------------------------------------------------------------
AAADfLAAGAAABq3AAA

SQL> alter table gh_range_example enable row movement;
Table altered

SQL> update gh_range_example t set t.range_date=trunc(sysdate) where t.range_date < trunc(sysdate)-10;
1 row updated

SQL> commit;
Commit complete

SQL>  select rowid from gh_range_example t where t.range_date = trunc(sysdate);
ROWID
--------------------------------------------------------------------------------
AAADfMAAGAAACU6AAA

SQL> 


行rowid发生变化,代表索引也是重新变化

如果遇到ORA-14402: updating partition key column would cause a partition change
开启 row movement;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值