REM Script: 18c merge online
Script: 18c merge online
REM Merge partitions on line without service interruption
Merge partitions on line without service interruption
drop table sales purge
ORA-00942: table or view does not existMore Details: https://docs.oracle.com/error-help/db/ora-00942
create table sales
( ts date,
id int,
amt number,
completed varchar2(1)
)
partition by range ( ts )
interval ( numtodsinterval(1,'DAY') )
(
partition p1 values less than ( date '2017-01-01' ),
partition p2 values less than ( date '2017-02-01' ),
partition p3 values less than ( date '2017-03-01' ),
partition p4 values less than ( date '2017-04-01' ),
partition p5 values less than ( date '2017-05-01' )
)
Table created.
insert /*+ APPEND */ into sales
select date '2017-01-01' - 10 + rownum / 100 ,rownum, dbms_random.value(1,100), null
from ( select 1 from dual connect by level <= 100 ),
( select 1 from dual connect by level <= 120 )
12000 row(s) inserted.
exec dbms_stats.gather_table_stats('','SALES')
Statement processed.
select partition_name, num_rows
from user_tab_partitions
where table_name = 'SALES'
order by partition_position
PARTITION_NAME | NUM_ROWS | P1 | 999 | P2 | 3100 | P3 | 2800 | P4 | 3100 | P5 | 2001 |
---|
create index sales_ix on sales ( id )
Index created.
alter table sales merge partitions p3, p4 into partition p3a update indexes online
Table altered.