简体   繁体   English

在Oracle中使用间隔分区对现有表进行分区

[英]Partition existing table using interval partitioning in Oracle

I want to partition an existing table in oracle 12 using interval partition and list subpartitions. 我想使用间隔分区和列表子分区在oracle 12中对现有表进行分区。 I have found some information on how to partition subsequently in range, but not using interval partition. 我发现了一些有关如何随后在范围内进行分区的信息,但没有使用间隔分区。 I want to tell the database the first partition and which value (date) it has and he will auto-create the rest for all datasets in the table. 我想告诉数据库第一个分区及其具有的值(日期),他将为表中的所有数据集自动创建其余分区。

ALTER TABLE TEST_TABLE MODIFY
 PARTITION BY RANGE(TESTDATE) INTERVAL (NUMTOYMINTERVAL(1, 'MONTH')) 
 SUBPARTITION BY LIST(COMPANY_NR) (
 PARTITION p1 VALUES LESS THAN (TO_DATE('01.01.2018 00:00:00', 'DD.MM.YYYY HH24:MI:SS'))
 (
    SUBPARTITION P_1 VALUES(1),
    SUBPARTITION P_2 VALUES(2)
  )
 );

Is the auto creation of the partitions with interval possible that way? 这样可以自动创建具有间隔的分区吗? I cannot find any info anywhere. 我在任何地方都找不到任何信息。 And if yes, what am I doing wrong here? 如果是的话,我在这里做错了什么? It says I am missing subpartition keyword. 它说我缺少子分区关键字。

You have to use SUBPARTITION TEMPLATE like this one: 您必须像这样使用SUBPARTITION TEMPLATE:

CREATE TABLE TEST_TABLE (...)
    PARTITION BY RANGE (TESTDATE) INTERVAL (NUMTOYMINTERVAL(1, 'MONTH')) 
    SUBPARTITION BY LIST (COMPANY_NR)
    SUBPARTITION TEMPLATE 
    (
        SUBPARTITION P_1 VALUES (1),
        SUBPARTITION P_2 VALUES (2)
        SUBPARTITION P_others VALUES (DEFAULT)
    )
    (
        PARTITION p1 VALUES LESS THAN (DATE '2018-01-01')
    );

You can change subpartition template on existing table, see Modifying a Subpartition Template 您可以在现有表上更改子分区模板,请参阅修改子分区模板。

However, if you like to change partition then you have to use the DBMS_REDEFINITION package. 但是,如果您想更改分区,则必须使用DBMS_REDEFINITION包。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM