点击(此处)折叠或打开
-
SQL> EXEC DBMS_REDEFINITION.START_REDEF_TABLE('SAPSR3', 'VBRP', 'VBRP_NEW20161221');
-
BEGIN DBMS_REDEFINITION.START_REDEF_TABLE('SAPSR3', 'VBRP', 'VBRP_NEW20161221'); END;
-
*
-
ERROR at line 1:
-
ORA-12008: error in materialized view refresh path
-
ORA-14400: inserted partition key does not map to any partition
-
ORA-06512: at "SYS.DBMS_REDEFINITION", line 56
-
ORA-06512: at "SYS.DBMS_REDEFINITION", line 1490
- ORA-06512: at line 1
解决的方法也是很简单的,就是删除VBRP_NEW20161221,然后修改下字段,再重新运行重定义即可。
点击(此处)折叠或打开
- drop materialized view log on VBRP
道理都懂,结果却错了一步,这个错误的时候应该先执行如下操作:
点击(此处)折叠或打开
-
BEGIN
-
DBMS_REDEFINITION.ABORT_REDEF_TABLE(uname => 'SAPSR3',
-
orig_table => 'VRP',
-
int_table => 'VBRP_NEW20161221'
-
);
- END
但是我却进行了物化视图和表的删除操作,当表修改完成之后,重新执行重定义的时候就报了ORA-42030的错误:
点击(此处)折叠或打开
-
SQL> EXEC DBMS_REDEFINITION.START_REDEF_TABLE('SAPSR3', 'VBRP', 'VBRP_NEW20161221');
-
*
-
ERROR at line 1:
-
ORA-42030: cannot online redefine table "SAPSR3"."VBRP" with commit SCN-based
-
MV log
-
ORA-06512: at "SYS.DBMS_REDEFINITION", line 56
-
ORA-06512: at "SYS.DBMS_REDEFINITION", line 1490
- ORA-06512: at line 1
【原因】因为删除了物化视图,但是当前表的物化视图日志还是存在的
【解决方法】找到问题后,原因很很简单,就是删除物化视图日志
点击(此处)折叠或打开
-
SQL> SELECT LOG_OWNER,MASTER,LOG_TABLE FROM DBA_MVIEW_LOGS;
-
LOG_OWNER MASTER LOG_TABLE
-
----------------------- ----------------- --------------------
- SAPSR3 VBRP MLOG$_VBRP
【解决方法】找到问题后,原因很很简单,就是删除物化视图日志
重新执行就可以了,
点击(此处)折叠或打开
-
SQL> BEGIN
-
DBMS_REDEFINITION.CAN_REDEF_TABLE('SAPSR3','VBRP',DBMS_REDEFINITION.CONS_USE_PK);
-
END;
-
/ 2 3 4
- PL/SQL procedure successfully completed.