采用分区的往往设置了一个max分区,想扩分区时会遇到ora-14704,需要用split拆分方式实现新增。
普通,没有设置max分区的,直接加即可:
-
create table test
-
(
-
msg_id integer,
-
insert_time date
-
)
-
partition by range (insert_time)
-
(
-
partition p2019 values less than (to_date(' 2019-12-31 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
-
tablespace users
-
pctfree 10
-
initrans 1
-
maxtrans 255,
-
partition p2020 values less than (to_date(' 2020-12-31 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
-
tablespace users
-
pctfree 10
-
initrans 1
-
maxtrans 255
-
);
-
-
alter table test add partition p2022 values less than (timestamp '2022-12-31 00:00:00');
设置max的需要split
-
--当前表结构,有maxvalue分区
-
create table test2
-
(
-
msg_id integer,
-
insert_time date
-
)
-
partition by range (insert_time)
-
(
-
partition p2019 values less than (to_date(' 2019-12-31 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
-
tablespace users
-
pctfree 10
-
initrans 1
-
maxtrans 255,
-
partition pmax values less than (maxvalue)
-
tablespace users
-
pctfree 10
-
initrans 1
-
maxtrans 255
-
);
-
-
--添加新分区(把最大的拆分)
-
alter table test2 split partition pmax at (to_date('2020-12-31','yyyy-mm-dd')) into (partition p2020 ,partition pmax);
-
-
--查看修改后的效果
-
create table test2
-
(
-
msg_id integer,
-
insert_time date
-
)
-
partition by range (insert_time)
-
(
-
partition p2019 values less than (to_date(' 2019-12-31 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
-
tablespace users
-
pctfree 10
-
initrans 1
-
maxtrans 255,
-
partition p2020 values less than (to_date(' 2020-12-31 00:00:00', 'syyyy-mm-dd hh24:mi:ss', 'nls_calendar=gregorian'))
-
tablespace users
-
pctfree 10
-
initrans 1
-
maxtrans 255,
-
partition pmax values less than (maxvalue)
-
tablespace users
-
pctfree 10
-
initrans 1
-
maxtrans 255
-
);
阅读(1849) | 评论(0) | 转发(0) |