Convert Non-partition table to partitioned table using ONLINE in Oracle PL/SQL

萝らか妹 提交于 2021-02-16 20:10:07

问题


I got to know as we cannot convert existing non-partitioned table to partitioned table but the below link from the Oracle suggest that with the help of "ONLINE" keyword we can do it.

https://docs.oracle.com/en/database/oracle/oracle-database/12.2/vldbg/evolve-nopartition-table.html#GUID-5FDB7D59-DD05-40E4-8AB4-AF82EA0D0FE5

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;

But it's not working for me, throwing error as "Invalid Partition Name".

I don't want to use dbms_redefinition.


回答1:


If you are using Oracle 12c Release 2 you could use single ALTER to convert non-partitioned table to partitioned one :

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;



回答2:


On Oracle Database 12c Release 1 (12.1.0.2.0) and without using dbms_redefinition your options may be limited to creating a new partitioned table with the same structure as the original table and copying over the data, creating indexes, constraints etc.

    CREATE TABLE my_tab_part -- new partitioned table
    PARTITION BY RANGE (a)
       INTERVAL ( 1000 )
       (PARTITION p1 VALUES LESS THAN (1000))
    AS
       SELECT * FROM my_tab;


来源:https://stackoverflow.com/questions/57668785/convert-non-partition-table-to-partitioned-table-using-online-in-oracle-pl-sql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!