PROBLEM:
Got error while doing online redefinition of a table, ORA-01442: column to be modified to NOT NULL is already NOT NULL.
DECLARE
error_count pls_integer := 0;
BEGIN
DBMS_REDEFINITION.COPY_TABLE_DEPENDENTS('RAJDBA', 'SOC_TABLE', 'SOC_TABLE_INTERIM', dbms_redefinition.cons_orig_params, TRUE,TRUE,TRUE,FALSE, error_count);
DBMS_OUTPUT.PUT_LINE('errors := ' || TO_CHAR(error_count));
END;
/
Session altered.
SQL>
Session altered.
SQL> SQL> SQL> 2 3 4 5 6 7
DECLARE
*
ERROR at line 1:
ORA-01442: column to be modified to NOT NULL is already NOT NULL
ORA-06512: at "SYS.DBMS_REDEFINITION", line 1746
ORA-06512: at "SYS.DBMS_REDEFINITION", line 2626
ORA-06512: at "SYS.DBMS_REDEFINITION", line 4009
ORA-06512: at line 4
SOLUTION:
Check whether you have any not null constraint present on the interim table:
SQL> select owner,CONSTRAINT_NAME,CONSTRAINT_TYPE,search_condition from dba_constraints where owner='RAJDBA' and table_name='SOC_TABLE_INTERIM' ;
-- if any not null constraint is reported, drop them.
SQL> alter table "RAJDBA"."SOC_TABLE_INTERIM" drop constraint SYS_C0013751;
Table altered.
SQL> alter table "RAJDBA"."SOC_TABLE_INTERIM" drop constraint SYS_C0013752;
Table altered.
SQL> alter table "RAJDBA"."SOC_TABLE_INTERIM" drop constraint SYS_C0013750;
Table altered.
Now rerun the DBMS_REDEFINITION.COPY_TABLE_DEPENDENTS process, it should work fine.
DECLARE
error_count pls_integer := 0;
BEGIN
DBMS_REDEFINITION.COPY_TABLE_DEPENDENTS('WMBREL', 'STC_BREL_AUDIT', 'STC_BREL_AUDIT_INT', dbms_redefinition.cons_orig_params, TRUE,TRUE,TRUE,FALSE, error_count);
DBMS_OUTPUT.PUT_LINE('errors := ' || TO_CHAR(error_count));
END;
/
SQL> SQL> SQL> 2 3 4 5 6 7
PL/SQL procedure successfully completed