The steps of Oracle table online redefination

Links: http://www.dbatools.net/experience/oracle_online_redefinition.html

    Online redefinition can be used to reduce the database down time in OLTP system. The first step is to check whether we can redefine it.

SQL>  exec dbms_redefinition.can_redef_table( USER, 'T_DEF1') ;

PL/SQL procedure successfully completed.

    Then we create a new table as target table with same structure as the source table, indexes can be created later, and grant the access to application schema. Now we start the data initialization.

SQL> exec dbms_redefinition.START_REDEF_TABLE( USER, 'T_DEF1', 'T_DEF1_TMP');

PL/SQL procedure successfully completed.

    Now you need to create the required indexes, and then schedule a job (run every 5 mins) to synchronize them.

SQL> exec dbms_redefinition.sync_interim_table( USER, 'T_DEF1', 'T_DEF1_TMP');

PL/SQL procedure successfully completed.

    During outage or after prime time, we can finish the online redefinition with less affection to the application.

SQL> exec dbms_redefinition.FINISH_REDEF_TABLE(USER, 'T_DEF1', 'T_DEF1_TMP');

PL/SQL procedure successfully completed.

    The base technology of online redefinition is Oracle's materialized view.

Post a comment

« Previous | Main | Next »

Powered by
Movable Type 3.36