Pages

Wednesday, July 24, 2024

Change Initial and Next extend size for partitioned table

Change Initial and Next extend size for partitioned table.
When changing the next and initial extend size for a Partitioned / Sub Partitioned Table, the change should be done on the Extend level

BUT!!!
For locally managed tablespaces, Oracle Database uses INITIAL , NEXT , PCTINCREASE , and MINEXTENTS to compute how many extents are allocated when the object is first created. After object creation, these parameters are ignored.
The only way to change exiting table, is to recreate it with the values for I
NITIAL and NEXT

For Example:

At Table level:
For future extends:

ALTER TABLE USER_A.TABLE MODIFY DEFAULT ATTRIBUTES STORAGE (INITIAL 81920 NEXT 65536);

At Partition level:
Modify Next extends on existing Partitions:

ALTER TABLE 
USER_A.TABLE MODIFY PARTITION P_DEFAULT STORAGE (NEXT 65536) ;

At SubPartition level: 
This should have rebuild the Sub Partition and change the initial extend. 
But it did not work...
ALTER TABLE USER_A.TABLE MOVE SUBPARTITION P_DEFAULT__S_20210904 ONLINE UPDATE INDEXES;

Need to recreate the table with correct initial and next extends, and populate data from backup table.

SELECT segment_name, 
       partition_name, 
       segment_type, 
       blocks, 
       initial_extent, 
       next_extent 
  FROM USER_SEGMENTS 
 WHERE segment_name= 'REP_DAILY_DNORM';


create table TABLE
(
  affiliate_id     NUMBER(10),
  date_of_record   VARCHAR2(8)
... 
...
)
partition by list (AFFILIATE_ID)
subpartition by range (DATE_OF_RECORD)
(
  partition P_DEFAULT values (0) tablespace IGT_REP_TABLE
  storage (initial 80K next 64K)
  (
    subpartition S_DEFAULT values less than ('0') tablespace IGT_REP_TABLE
  ),
  partition P_54 values (54) tablespace IGT_REP_TABLE
  storage (initial 80K next 64K)
(
    subpartition P_54_S_DEFAULT values less than ('0') tablespace IGT_REP_TABLE
  ),
  partition P_606 values (606) tablespace IGT_REP_TABLE
  storage (initial 80K next 64K)  
(
    subpartition P_606_S_DEFAULT values less than ('0') tablespace IGT_REP_TABLE,
    subpartition P_606_S_20240524 values less than ('20240525') tablespace IGT_REP_TABLE,
    subpartition P_606_S_20240525 values less than ('20240526') tablespace IGT_REP_TABLE,
    subpartition P_606_S_20240526 values less than ('20240527') tablespace IGT_REP_TABLE,
    subpartition P_606_S_20240527 values less than ('20240528') tablespace IGT_REP_TABLE,
    subpartition P_606_S_20240528 values less than ('20240529') tablespace IGT_REP_TABLE,
    subpartition P_606_S_20240529 values less than ('20240530') tablespace IGT_REP_TABLE,
    subpartition P_606_S_20240530 values less than ('20240531') tablespace IGT_REP_TABLE,
    subpartition P_606_S_20240531 values less than ('20240601') tablespace IGT_REP_TABLE,
    subpartition P_606_S_20240601 values less than ('20240602') tablespace IGT_REP_TABLE,
    subpartition P_606_S_20240602 values less than ('20240603') tablespace IGT_REP_TABLE,
    subpartition P_606_S_20240723 values less than ('20240724') tablespace IGT_REP_TABLE
...
...
  )
);

No comments:

Post a Comment