-- Step 01:
Check Whether table ocdw.DEPOSIT_ACCT_INDICATOR_B can be redefined online.
SQL> exec dbms_redefinition.can_redef_table('OCDW', 'DEPOSIT_ACCT_INDICATOR_B');
PL/SQL procedure successfully completed.
-- Step 02:
Create an interim table ocdw.DEPOSIT_ACCT_INDICATOR_B_ which holds the same structure as the original table except constraints, indexes, triggers but add the partitioning attribute.
SQL>@DEPOSIT_ACCT_INDICATOR_B.sql
Later this table can be dropped.
The DDL at table level should also not contain NOT NULL or any constraints. The NOT NULL contraints at table level if defined in the original table then it will be enforced as constraints after completion of all the steps not at table level.
-- Step 03:
Initiates the redefinition process by calling dbms_redefinition.start_redef_table procedure.
SQL> exec dbms_redefinition.start_redef_table('OCDW', 'DEPOSIT_ACCT_INDICATOR_B', 'DEPOSIT_ACCT_INDICATOR_B_');
PL/SQL procedure successfully completed.
If any error encountered while running this process then abort the redifinition process first using below statements:
SQL> exec dbms_redefinition.abort_redef_table('OCDW', 'DEPOSIT_ACCT_INDICATOR_B', 'DEPOSIT_ACCT_INDICATOR_B_');
Resolve the error and restart the redefinition process.
-- Step 04:
Copies the dependent objects of the original table onto the interim table. The COPY_TABLE_DEPENDENTS Procedure clones the dependent objects of the table being redefined onto the interim table and registers the dependent objects. But this procedure does not clone the already registered dependent objects.
In fact COPY_TABLE_DEPENDENTS Procedure is used to clone the dependent objects like grants, triggers, constraints and privileges from the table being redefined to the interim table which in fact represents the post-redefinition table.
SQL>@copy_table_dependents.sql
The content of this sql file is as below:
DECLARE
error_count PLS_INTEGER := 0;
BEGIN
dbms_redefinition.copy_table_dependents('OCDW', 'DEPOSIT_ACCT_INDICATOR_B', 'DEPOSIT_ACCT_INDICATOR_B_',1, TRUE, TRUE, TRUE, FALSE,error_count);
DBMS_OUTPUT.PUT_LINE('errors := ' || TO_CHAR(error_count));
END;
/
If any constraints are created on interim table (even NOT NULL), the above PL/SQL will fail.
-- Step 05:
Completes the redefinition process by calling FINISH_REDEF_TABLE Procedure.
SQL> exec dbms_redefinition.finish_redef_table('OCDW', 'DEPOSIT_ACCT_INDICATOR_B', 'DEPOSIT_ACCT_INDICATOR_B_');
-- Step 06:
Check the partitioning validation by:
SQL> Select partition_name, high_value from user_tab_partitions where table_name='DEPOSIT_ACCT_INDICATOR_B';
-- Step 07:
Check index status by
SQL> select index_name , status from user_indexes where table_name='DEPOSIT_ACCT_INDICATOR_B';
-- Step 08:
Check the constraints
SELECT owner,constraint_name,constraint_type,serach_condition,status
FROM dba_constraints WHERE table_name='DEPOSIT_ACCT_INDICATOR_B';
Check for the NOT NULL constraints. Any constraint defined at table level on original table is now enforced by system generated constraints.
-- Step 09:
Drop the interim table DEPOSIT_ACCT_INDICATOR_B_.
SQL> drop table ocdw.DEPOSIT_ACCT_INDICATOR_B_;
Check Whether table ocdw.DEPOSIT_ACCT_INDICATOR_B can be redefined online.
SQL> exec dbms_redefinition.can_redef_table('OCDW', 'DEPOSIT_ACCT_INDICATOR_B');
PL/SQL procedure successfully completed.
-- Step 02:
Create an interim table ocdw.DEPOSIT_ACCT_INDICATOR_B_ which holds the same structure as the original table except constraints, indexes, triggers but add the partitioning attribute.
SQL>@DEPOSIT_ACCT_INDICATOR_B.sql
Later this table can be dropped.
The DDL at table level should also not contain NOT NULL or any constraints. The NOT NULL contraints at table level if defined in the original table then it will be enforced as constraints after completion of all the steps not at table level.
-- Step 03:
Initiates the redefinition process by calling dbms_redefinition.start_redef_table procedure.
SQL> exec dbms_redefinition.start_redef_table('OCDW', 'DEPOSIT_ACCT_INDICATOR_B', 'DEPOSIT_ACCT_INDICATOR_B_');
PL/SQL procedure successfully completed.
If any error encountered while running this process then abort the redifinition process first using below statements:
SQL> exec dbms_redefinition.abort_redef_table('OCDW', 'DEPOSIT_ACCT_INDICATOR_B', 'DEPOSIT_ACCT_INDICATOR_B_');
Resolve the error and restart the redefinition process.
-- Step 04:
Copies the dependent objects of the original table onto the interim table. The COPY_TABLE_DEPENDENTS Procedure clones the dependent objects of the table being redefined onto the interim table and registers the dependent objects. But this procedure does not clone the already registered dependent objects.
In fact COPY_TABLE_DEPENDENTS Procedure is used to clone the dependent objects like grants, triggers, constraints and privileges from the table being redefined to the interim table which in fact represents the post-redefinition table.
SQL>@copy_table_dependents.sql
The content of this sql file is as below:
DECLARE
error_count PLS_INTEGER := 0;
BEGIN
dbms_redefinition.copy_table_dependents('OCDW', 'DEPOSIT_ACCT_INDICATOR_B', 'DEPOSIT_ACCT_INDICATOR_B_',1, TRUE, TRUE, TRUE, FALSE,error_count);
DBMS_OUTPUT.PUT_LINE('errors := ' || TO_CHAR(error_count));
END;
/
If any constraints are created on interim table (even NOT NULL), the above PL/SQL will fail.
-- Step 05:
Completes the redefinition process by calling FINISH_REDEF_TABLE Procedure.
SQL> exec dbms_redefinition.finish_redef_table('OCDW', 'DEPOSIT_ACCT_INDICATOR_B', 'DEPOSIT_ACCT_INDICATOR_B_');
-- Step 06:
Check the partitioning validation by:
SQL> Select partition_name, high_value from user_tab_partitions where table_name='DEPOSIT_ACCT_INDICATOR_B';
-- Step 07:
Check index status by
SQL> select index_name , status from user_indexes where table_name='DEPOSIT_ACCT_INDICATOR_B';
-- Step 08:
Check the constraints
SELECT owner,constraint_name,constraint_type,serach_condition,status
FROM dba_constraints WHERE table_name='DEPOSIT_ACCT_INDICATOR_B';
Check for the NOT NULL constraints. Any constraint defined at table level on original table is now enforced by system generated constraints.
-- Step 09:
Drop the interim table DEPOSIT_ACCT_INDICATOR_B_.
SQL> drop table ocdw.DEPOSIT_ACCT_INDICATOR_B_;
No comments:
Post a Comment