Oracle table dynamic partition

前端 未结 1 1280
Happy的楠姐
Happy的楠姐 2021-01-16 02:33

I\'m working on a java code to upload data from oracle tables every 15mins based from the INSERT_DATETIME field (timestamp). I need to partition the tables based on 15minute

1条回答
  •  走了就别回头了
    2021-01-16 03:22

    Create the table with interval partitioning:

    CREATE TABLE TEJAS_CARD_REPORT
    (
        "INSERT_DATETIME" TIMESTAMP (6) NOT NULL ENABLE, 
        "NAME"         VARCHAR2(100 BYTE), 
        "IPADDRESS" VARCHAR2(100 BYTE), 
        "PRODUCTCODE" VARCHAR2(100 BYTE), 
        "LCTNAME" VARCHAR2(100 BYTE), 
        "CARDTYPELABEL" VARCHAR2(100 BYTE), 
        "SOFTWAREVERSION" VARCHAR2(100 BYTE)
    ) partition by range(insert_datetime) interval (interval '15' minute)
    (
        partition initial_partition values less than (date '2000-01-01')
    );
    

    Partitions are dynamically created as data is inserted.

    insert into tejas_card_report(insert_datetime) values (timestamp '2000-01-01 00:14:00');
    insert into tejas_card_report(insert_datetime) values (timestamp '2000-01-01 00:29:00');
    insert into tejas_card_report(insert_datetime) values (timestamp '2000-10-11 00:00:00');
    
    SQL> select partition_name, high_value from dba_tab_partitions where table_name = 'TEJAS_CARD_REPORT';
    
    PARTITION_NAME       HIGH_VALUE
    -------------------- --------------------------------------------------------------------------------
    SYS_P21516           TIMESTAMP' 2000-10-11 00:15:00'
    SYS_P21515           TIMESTAMP' 2000-01-01 00:30:00'
    SYS_P21514           TIMESTAMP' 2000-01-01 00:15:00'
    INITIAL_PARTITION    TIMESTAMP' 2000-01-01 00:00:00'
    

    On an unrelated note, avoid TABLESPACE "SYSTEM". You almost never want to store any user or application data in the SYSTEM tablespace.

    0 讨论(0)
提交回复
热议问题