How do I alter my existing table to create a range partition in Oracle

后端 未结 2 1693
滥情空心
滥情空心 2021-01-02 09:58

I have existing table which has 10 years of data (I have taken dump).

I would like to Range partition the existing table on one date key column within the table.

2条回答
  •  独厮守ぢ
    2021-01-02 10:41

    If you are using Oracle 12c Release 2 you could use single ALTER to convert non-partitioned table to partitioned one (this is one way trip):

    CREATE TABLE my_tab ( a NUMBER(38,0), b NUMBER(38,0)); 
    
    ALTER TABLE MY_TAB MODIFY PARTITION BY RANGE (a) INTERVAL (1000) (   
        PARTITION p1 VALUES LESS THAN (1000)) ONLINE;
    

    You could convert indexes too, adding:

    update indexes (index_name [local/global]);
    

    db<>fiddle demo

提交回复
热议问题