2

我需要有关将分区添加到现有手动分区表的建议。我的案例:版本:Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - 生产现有表数据类型:总行数:13495522

   CREATE TABLE NJIISPROD.TEMP_TABLE
           (  ID_SEQ                 NUMBER(12),
              USER_CREATED           NUMBER(12) CONSTRAINT NN_TEMP_TABLE_USR_CRTD NOT NULL,
              DATE_CREATED           DATE CONSTRAINT NN_TEMP_TABLE_DATE_CRTD NOT NULL,
              USER_UPDATED           NUMBER(12) CONSTRAINT NN_TEMP_TABLE_USR_UPTD NOT NULL,
              DATE_UPDATED           DATE CONSTRAINT NN_TEMP_TABLE_DATE_UPTD NOT NULL,
              USER_DELETED           NUMBER(12),
              DATE_DELETED           DATE
            )
            PARTITION BY RANGE (ID_SEQ)
            (  
              PARTITION P1 VALUES LESS THAN (100001),  
              PARTITION P2 VALUES LESS THAN (200001),  
              PARTITION P70 VALUES LESS THAN (MAXVALUE)
            )
            MONITORING
            ENABLE ROW MOVEMENT      
        ;

高分区统计:

Name    Position    High Value  Tablespace  Compression Num Rows    Blocks  
P70      70         MAXVALUE    TABSPACE    DISABLED    6,544,623   79,229  

我们曾经通过拆分最大分区来手动添加分区,但是最大分区中的行数看起来不是一个可行的解决方案。这导致我们使用 dbms_redefinition 包。

我当前使用 dbms_redefinition 自动分区表的解决方案的步骤:

CREATE TABLE NJIISPROD.TEMP_TABLE_A
(
  ID_SEQ                 NUMBER(12),
  USER_CREATED           NUMBER(12) ,
  DATE_CREATED           DATE ,
  USER_UPDATED           NUMBER(12),
  DATE_UPDATED           DATE ,
  USER_DELETED           NUMBER(12),
  DATE_DELETED           DATE
)
PARTITION BY RANGE (ID_SEQ) INTERVAL (100000)
(  
PARTITION P1 VALUES LESS THAN (100001),
PARTITION P2 VALUES LESS THAN (200001)  
)
ENABLE ROW MOVEMENT;

EXEC DBMS_REDEFINITION.can_redef_table(USER, 'TEMP_TABLE');

ALTER SESSION FORCE PARALLEL DML PARALLEL 8;
ALTER SESSION FORCE PARALLEL QUERY PARALLEL 8;

BEGIN
  DBMS_REDEFINITION.start_redef_table(
    uname      => USER,        
    orig_table => 'TEMP_TABLE',
    int_table  => 'TEMP_TABLE2');
END;
/

BEGIN
  dbms_redefinition.sync_interim_table(
    uname      => USER,        
    orig_table => 'TEMP_TABLE',
    int_table  => 'TEMP_TABLE2');
END;
/

SET SERVEROUTPUT ON
DECLARE
  l_errors  NUMBER;
BEGIN
  DBMS_REDEFINITION.copy_table_dependents(
    uname            => USER,
    orig_table       => 'TEMP_TABLE',
    int_table        => 'TEMP_TABLE2',
    copy_indexes     => 0,--DBMS_REDEFINITION.cons_orig_params,
    copy_triggers    => TRUE,
    copy_constraints => TRUE,
    copy_privileges  => TRUE,
    ignore_errors    => FALSE,
    num_errors       => l_errors,
    copy_statistics  => FALSE,
    copy_mvlog       => FALSE);
    
  DBMS_OUTPUT.put_line('Errors=' || l_errors);
END;
/
 select object_name, base_table_name, ddl_txt from DBA_REDEFINITION_ERRORS;
--create indexes manually 

EXEC DBMS_STATS.gather_table_stats(USER, 'TEMP_TABLE2', cascade => TRUE);

BEGIN
  dbms_redefinition.finish_redef_table(
    uname      => USER,        
    orig_table => 'TEMP_TABLE',
    int_table  => 'TEMP_TABLE2');
END;
/
DROP TABLE TEMP_TABLE2;

在较低的车道上,DBMS_REDEFINITION.start_redef_table 进程(13495522 条记录)花了我 7 个多小时。

我想知道是否有任何其他方法可以自动化分区。

4

0 回答 0