本帖最后由 郑全 于 2020-6-9 18:52 编辑
我创建了一张表,本来需要间隔分区,结果创建分区时,给忘了,
CREATE TABLE sztech(ID NUMBER(8),
UPDATE_TIME DATE)
PARTITION BY RANGE(UPDATE_TIME)
(PARTITION P1 VALUES LESS THAN(TO_DATE('2020-06-01','YYYY-MM-DD'))
);
当发现时,已经有很多数据,如何增加这个间隔分区呢 ?
select TABLE_NAME,PARTITIONING_TYPE,INTERVAL from dba_part_tables where table_name in 'SZTECH';
TABLE_NAME PARTITIONING_TYPE INTERVAL
-------------------- ----------------- --------------------------------------------------------------------------------
SZTECH RANGE
我们只需要直接修改即可:
ALTER TABLE sztech SET INTERVAL (numtoyminterval(1,'month'));
TABLE_NAME PARTITIONING_TYPE INTERVAL
-------------------- ----------------- ------------------------------
SZTECH RANGE NUMTOYMINTERVAL(1,'MONTH')
INSERT INTO SZTECH VALUES(100,SYSDATE);
select table_name,partition_name, high_value, partition_position
from dba_tab_partitions
where table_name like 'SZTECH';
TABLE_NAME PARTITION_NAME HIGH_VALUE PARTITION_POSITION
-------------------- -------------------- -------------------------------------------------------------------------------- ------------------
SZTECH P1 TO_DATE(' 2020-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 1
SZTECH SYS_P566 TO_DATE(' 2020-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA 2
看到已经新增一个分区了。
|