Oracle 18c New Feature: Online Modification of Partitioning

Oracle 18c New Feature: Online Modification of Partitioning

In Oracle Database 18c we now change the partitioning strategy online of a table via the “ALTER TABLE MODIFY PARTITION” SQL statement.

This new feature enable us to adapt the partitioning method for a table without requiring any associated downtime for making the change.

Unless you specify “UPDATE INDEXES” clause as part of the “ALTER TABLE” statement:

– The database marks UNUSABLE all resulting corresponding local index partitions or subpartitions.
– Global indexes, or all partitions of partitioned global indexes, are marked UNUSABLE and must be rebuilt.

This example provides a step by step demonstration of the tasks required to convert RANGE partition table to a HASH partition table.

Display the partitions of the table ATP01_CRED_PAG:


# sqlplus / as sysdba

SQL*Plus: Release 18.0.0.0.0 - Production on Wed Jun 17 16:39:51 2020
Version 18.2.0.0.0

Copyright (c) 1982, 2018, Oracle. All rights reserved.

Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.2.0.0.0

SQL> select table_name, partition_name, partition_position from dba_tab_partitions where table_name='ATP01_CRED_PAG';

TABLE_NAME PARTITION_NAME PARTITION_POSITION
-----------------------------------------------------
ATP01_CRED_PAG PART_199501 1
ATP01_CRED_PAG PART_199412 2
ATP01_CRED_PAG PART_199506 3

SQL> select count(1) from ATP01_CRED_PAG partition (PART_199501);

COUNT(1)
----------
3908

SQL> select count(1) from ATP01_CRED_PAG partition (PART_199412);

COUNT(1)
----------
3984

SQL> select count(1) from ATP01_CRED_PAG partition (PART_199506);

COUNT(1)
----------
1363

 

Display the partitioning method (RANGE) of the table ATP01_CRED_PAG:


SQL> select owner, table_name, partitioning_type, autolist, interval, autolist_subpartition from dba_part_tables where table_name = 'ATP01_CRED_PAG';

OWNER TABLE_NAME PARTITION AUT INTERVAL AUT
-------- -------------- -------- ---- --------- ------
ADMIN ATP01_CRED_PAG RANGE NO NO

 

Convert RANGE Partitioned table to HASH partitioned table ONLINE:


SQL> ALTER TABLE ATP01_CRED_PAG MODIFY PARTITION BY HASH (DT_COMPETENCIA) PARTITIONS 3 ONLINE;

Table altered.

 

Displays the new partitioning method (HASH):


SQL> select owner, table_name, partitioning_type, autolist, interval, autolist_subpartition from dba_part_tables where table_name = 'ATP01_CRED_PAG';

OWNER TABLE_NAME PARTITION AUT INTERVAL AUT
-------- ------------- --------- --- -------- -----
ADMIN ATP01_CRED_PAG HASH NO NO

 

Display the partitions of the table:


SQL> select table_name, partition_name, partition_position from dba_tab_partitions where table_name='ATP01_CRED_PAG';

TABLE_NAME PARTITION_NAME PARTITION_POSITION
----------------- ---------------- ------------------
ATP01_CRED_PAG SYS_P621 1
ATP01_CRED_PAG SYS_P622 2
ATP01_CRED_PAG SYS_P623 3

SQL> select count(1) from ATP01_CRED_PAG partition (SYS_P621);

COUNT(1)
----------
2651

SQL> select count(1) from ATP01_CRED_PAG partition (SYS_P622);

COUNT(1)
----------
6604

SQL> select count(1) from ATP01_CRED_PAG partition (SYS_P623);

COUNT(1)
----------
0

References

Maintenance Operations for Partitioned Tables and Indexes. Available at https://docs.oracle.com/en/database/oracle/oracle-database/18/vldbg/maintenance-partition-tables-indexes.html#GUID-0E7793F7-B38A-427E-846B-7A8651F2A523