Above the 12c version of online table partition (do not use online redefinition)

Start 12c, partition table online, you can not use the online redefined. Aleter table modify may be used as a way to partition.

Reference documents:

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

RDBMS 19.6.0.0 Test Environment

- Create a table of test

SQL> create table employees_convert as select * from hr.employees;

Table created.

SQL>

- the test table to convert (in the sys does not support doing so)

ALTER TABLE employees_convert MODIFY
  PARTITION BY RANGE (employee_id) INTERVAL (100)
  ( PARTITION P1 VALUES LESS THAN (150),
    PARTITION P2 VALUES LESS THAN (200)
   ) ONLINE
  UPDATE INDEXES
 ( IDX1_SALARY LOCAL,
   IDX2_EMP_ID GLOBAL PARTITION BY RANGE (employee_id)
  ( PARTITION IP1 VALUES LESS THAN (MAXVALUE))
 );
 
 SQL> ALTER TABLE employees_convert MODIFY
  PARTITION BY RANGE (employee_id) INTERVAL (100)
  ( PARTITION P1 VALUES LESS THAN (150),
    PARTITION P2 VALUES LESS THAN (200)
   ) ONLINE
  2    3    4    5    6    UPDATE INDEXES
 ( IDX1_SALARY LOCAL,
   IDX2_EMP_ID GLOBAL PARTITION BY RANGE (employee_id)
  ( PARTITION IP1 VALUES LESS THAN (MAXVALUE))
 );  7    8    9   10
ALTER TABLE employees_convert MODIFY
            *
ERROR at line 1:
ORA-14809: schema does not support ONLINE MODIFY PARTITION BY DDL


SQL>

- for the other schema do

SQL> conn hr/oracle
Connected.
SQL> create table employees_convert as select * from hr.employees;

Table created.

SQL> ALTER TABLE employees_convert MODIFY
  PARTITION BY RANGE (employee_id) INTERVAL (100)
  ( PARTITION P1 VALUES LESS THAN (150),
  2    3    4      PARTITION P2 VALUES LESS THAN (200)
   ) ONLINE
  5    6    UPDATE INDEXES
  7   ( IDX1_SALARY LOCAL,
   IDX2_EMP_ID GLOBAL PARTITION BY RANGE (employee_id)
  ( PARTITION IP1 VALUES LESS THAN (MAXVALUE))
 );  8    9   10
 ( IDX1_SALARY LOCAL,
   *
ERROR at line 7:
ORA-01418: specified index does not exist       -- 因为这里要用到索引,新创建的表上没有索引,所以会出错。先不使用索引,等分区后,再手工创建索引。
SQL>

SQL> ALTER TABLE employees_convert MODIFY
  PARTITION BY RANGE (employee_id) INTERVAL (100)
  ( PARTITION P1 VALUES LESS THAN (150),
    PARTITION P2 VALUES LESS THAN (200)
   ) ONLINE  2    3    4    5
  6  ;

Table altered.

SQL>

- View Subdivision

SQL> select table_name,partition_name from user_tab_partitions where table_name='EMPLOYEES_CONVERT' ;

TABLE_NAME           PARTITION_
-------------------- ----------
EMPLOYEES_CONVERT    P1
EMPLOYEES_CONVERT    P2
EMPLOYEES_CONVERT    SYS_P522

SQL>

Some description of the update index statement

Considerations When Using the UPDATE INDEXES Clause

When using the UPDATE INDEXES clause, note the following.

  • This clause can be used to change the partitioning state of indexes and storage properties of the indexes being converted.

  • The specification of the UPDATE INDEXES clause is optional.

    Indexes are maintained both for the online and offline conversion to a partitioned table.

  • This clause cannot change the columns on which the original list of indexes are defined.

  • This clause cannot change the uniqueness property of the index or any other index property.

  • If you do not specify the tablespace for any of the indexes, then the following tablespace defaults apply.

    • Local indexes after the conversion collocate with the table partition.

    • Global indexes after the conversion reside in the same tablespace of the original global index on the non-partitioned table.

  • If you do not specify the INDEXES clause or the INDEXES clause does not specify all the indexes on the original non-partitioned table, then the following default behavior applies for all unspecified indexes.

    • Global partitioned indexes remain the same and retain the original partitioning shape.

    • Non-prefixed indexes become global nonpartitioned indexes.

    • Prefixed indexes are converted to local partitioned indexes.

      Prefixed means that the partition key columns are included in the index definition, but the index definition is not limited to including the partitioning keys only.

    • Bitmap indexes become local partitioned indexes, regardless whether they are prefixed or not.

      Bitmap indexes must always be local partitioned indexes.

  • The conversion operation cannot be performed if there are domain indexes.

 

END

Published 756 original articles · won praise 32 · Views 200,000 +

Guess you like

Origin blog.csdn.net/xxzhaobb/article/details/104074253