Overview
Oracle Partitioning splits tables and indexes by a key (range, list, hash, composite, interval, reference). It gives partition pruning, fast data lifecycle and parallel operations. General ideas are in table-partitioning. In Oracle Database Enterprise Edition it is a separately licensed option; v$option reported Partitioning = TRUE in the Free build used here, so verify licensing for your edition.
Core concepts
- Range: ordered key ranges (dates). Interval: a range scheme where Oracle creates new partitions automatically when data arrives beyond the last range. List, hash, and composite (range-hash, etc.) schemes also exist.
- Local indexes have one index partition per table partition (they follow partition maintenance); global indexes span all partitions and traditionally need maintenance on
DROP/TRUNCATE PARTITION(useUPDATE GLOBAL INDEXES). A unique local index must contain the partition key. - Maintenance commands:
ADD,DROP,TRUNCATE,SPLIT,MERGE,EXCHANGE PARTITION(swap a partition with a standalone table, instantaneous like SQL Server’sSWITCH, sqlserver-partitioning). - Plan operations show
PARTITION RANGE SINGLE | ITERATOR | ALLwithPstart/Pstop(oracle-execution-plans).
Worked example
Interval partitioning by month, 30,000 rows from January to March:
CREATE TABLE ev (
id NUMBER GENERATED ALWAYS AS IDENTITY, created DATE NOT NULL, payload VARCHAR2(20))
PARTITION BY RANGE (created) INTERVAL (NUMTOYMINTERVAL(1, 'MONTH'))
(PARTITION p_old VALUES LESS THAN (DATE '2025-02-01'));
-- after the insert, Oracle created the extra partitions itself:
-- P_OLD (10,454 rows), SYS_P673 (9,436), SYS_P674 (10,110)Partition pruning for a ten-day range:
| Operation | Name | Pstart | Pstop |
| PARTITION RANGE SINGLE | | 2 | 2 |
| TABLE ACCESS FULL | EV | 2 | 2 |Only partition 2 was read. Retiring January:
ALTER TABLE ev DROP PARTITION p_old UPDATE GLOBAL INDEXES; -- 19,546 rows remainPitfalls and production notes
- System-generated partition names (
SYS_P673) are awkward; rename withALTER TABLE ... RENAME PARTITIONor use automatic naming conventions. - Filter on the partition key with the matching data type; implicit conversions or functions on the key prevent pruning.
- Choose the key by how data is queried and aged; too many partitions lengthen parse and maintenance times.
- Online conversion of a non-partitioned table:
ALTER TABLE ... MODIFY PARTITION BY ... ONLINE(12.2 and later). - Partitioned tables need statistics at both partition and global level; use incremental statistics for large tables (oracle-optimizer-statistics).
Practice questions
- What does interval partitioning remove from the DBA’s routine?
- Local vs global index: which is easier to maintain with a monthly drop, and why?
- How would you load a month of data without blocking readers using
EXCHANGE PARTITION?
References
- Oracle Database VLDB and Partitioning Guide
Related
table-partitioning · sqlserver-partitioning · oracle-indexes · oracle-storage-tablespaces