在对分区表操作是,当一个分区已经有了最大的分区,如何再次扩展分区呢?简单的方式是先删除最大分区,然后添加需要的分区,再次建立最大分区,如果对于7*24小时的系统,可能不行。哪有什么办法呢?下面来做个试验:
SQL> select * from v$version;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for 64-bit Windows: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
SQL> drop table test purge;
SQL> create table test
(
id number,
record_date date
)partition by range(record_date)
(
partition p_2013 values less than(to_date(‘2013-01-01‘,‘yyyy-MM-dd‘)),
partition p_2014 values less than(to_date(‘2014-01-01‘,‘yyyy-MM-dd‘)),
partition p_max values less than (maxvalue)
);
SQL> insert into test values(1,to_date(‘2012-10-01‘,‘yyyy-MM-dd‘));
SQL> insert into test values(2,to_date(‘2013-10-01‘,‘yyyy-MM-dd‘));
SQL> insert into test values(3,to_date(‘2014-10-01‘,‘yyyy-MM-dd‘));
SQL> commit;
SQL> select partition_name from user_tab_partitions
where table_name = ‘TEST‘
order by partition_position;
PARTITION_NAME
------------------------------
P_2013
P_2014
P_MAX
SQL> select * from test partition(p_2013);
ID RECORD_DATE
---------- --------------
1 01-10月-12
SQL> select * from test partition(p_2014);
ID RECORD_DATE
---------- --------------
2 01-10月-13
SQL> select * from test partition(p_max);
ID RECORD_DATE
---------- --------------
3 01-10月-14
SQL> alter table test add partition p_2015 values
less than(to_date(‘2015-10-01‘,‘yyyy-MM-dd‘));
alter table test add partition p_2015 values
*
第 1 行出现错误:
ORA-14074: 分区界限必须调整为高于最后一个分区界限
SQL> alter table test split partition p_max at (to_date(‘2015-01-01‘,‘yyyy-MM-dd‘))
into (partition p_2015, partition p_max) update global indexes;
SQL> select partition_name from user_tab_partitions
where table_name = ‘TEST‘
order by partition_position;
PARTITION_NAME
------------------------------
P_2013
P_2014
P_2015
P_MAX
SQL> insert into test values(4,to_date(‘2015-10-01‘,‘yyyy-MM-dd‘));
SQL> commit;
SQL> select * from test partition(p_2015);
ID RECORD_DATE
---------- --------------
3 01-10月-14
SQL> select * from test partition(p_max);
ID RECORD_DATE
---------- --------------
4 01-10月-15