Mastering Oracle Table Partitioning: Weekly & Alphabetical Subpartitions

Learn to partition huge SQL tables by date weekly and sub-partition alphabetically by station name. A practical guide for Oracle.

Learn to partition huge SQL tables by date weekly and sub-partition alphabetically by station name. A practical guide for Oracle.

Partition by date keeping weekly and sub partition by station name alphabetically for huge records in separate sub partition.

PARTITION BY RANGE (CREATED_DATE) INTERVAL (numtodsinterval(7, 'DAY')) 
SUBPARTITION BY RANGE(STATION)
    SUBPARTITION TEMPLATE (
        SUBPARTITION SUB_PART_A VALUES LESS THAN ('B%'),
        SUBPARTITION SUB_PART_B VALUES LESS THAN ('C%'),
        SUBPARTITION SUB_PART_C VALUES LESS THAN ('D%'),
        SUBPARTITION SUB_PART_D VALUES LESS THAN ('E%'),
        SUBPARTITION SUB_PART_E VALUES LESS THAN ('F%'),
        SUBPARTITION SUB_PART_F VALUES LESS THAN ('G%'),
        SUBPARTITION SUB_PART_G VALUES LESS THAN ('H%'),
        SUBPARTITION SUB_PART_H VALUES LESS THAN ('I%'),
        SUBPARTITION SUB_PART_I VALUES LESS THAN ('J%'),
        SUBPARTITION SUB_PART_J VALUES LESS THAN ('K%'),
        SUBPARTITION SUB_PART_K VALUES LESS THAN ('L%'),
        SUBPARTITION SUB_PART_L VALUES LESS THAN ('M%'),
        SUBPARTITION SUB_PART_M VALUES LESS THAN ('N%'),
        SUBPARTITION SUB_PART_N VALUES LESS THAN ('O%'),
        SUBPARTITION SUB_PART_O VALUES LESS THAN ('P%'),
        SUBPARTITION SUB_PART_P VALUES LESS THAN ('Q%'),
        SUBPARTITION SUB_PART_Q VALUES LESS THAN ('R%'),
        SUBPARTITION SUB_PART_R VALUES LESS THAN ('S%'),
        SUBPARTITION SUB_PART_S VALUES LESS THAN ('T%'),
        SUBPARTITION SUB_PART_T VALUES LESS THAN ('U%'),
        SUBPARTITION SUB_PART_U VALUES LESS THAN ('V%'),
        SUBPARTITION SUB_PART_V VALUES LESS THAN ('W%'),
        SUBPARTITION SUB_PART_W VALUES LESS THAN ('X%'),
        SUBPARTITION SUB_PART_X VALUES LESS THAN ('Y%'),
        SUBPARTITION SUB_PART_Y VALUES LESS THAN ('Z%'),
        SUBPARTITION SUB_PART_Z_0_9 VALUES LESS THAN (MAXVALUE)
        )   
(
PARTITION OLD_PART_DATA VALUES LESS THAN (TO_DATE('01-AUG-2018', 'dd-mon-yyyy'))
);

 

Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments