和上一篇文章不同,上一篇的目的是减少哪些可能造成危害的错误。而本篇文章的目的是尽可能减少所有的错误。有些错误完全可以忽略,没有必要一定消除干净,本文纯粹以技术探讨为主,真正进行全库导入时,没有必要仿效。
执行完第一篇文章的导入前期步骤,ORA-错误还有85个,而IMP-错误还有351个。
观察testmv_full.log发现了一些IMP-00015错误:IMP-00015: 由于对象已存在,下列语句失败。
这些错误是由于同名同义词已经存在造成的,简单删除掉这些同名同义词就可以了。
在日志文档中还出现了下面的错误信息:
IMP-00017: 由于 ORACLE 的 6550 错误,以下的语句失败
"BEGIN "
""
"DECLARE "
" dummy integer;"
"BEGIN"
" select 1 into dummy from dual "
" where exists (select 1 from all_synonyms"
" where owner = 'PUBLIC' and synonym_name = 'DBMS_WM');"
"EXCEPTION "
" when NO_DATA_FOUND then "
" RAISE_APPLICATION_ERROR(-20000, 'OWM Not Installed');"
"END;"
""
"IF (sys.ltadm.existnonliveworkspaces OR"
"sys.ltadm.existversionedtabs) "
"THEN"
" SYS.WM_ERROR.RAISEERROR(SYS.LT.WM_ERROR_189_NO);"
"ELSE"
""
"begin"
"delete from wmsys.wm$workspaces_table;"
"exception when others then null;"
"end;"
""
"begin"
"delete from wmsys.wm$workspace_priv_table;"
"exception when others then null;"
"end;"
""
"begin"
"delete from wmsys.wm$version_hierarchy_table ;"
"exception when others then null;"
"end;"
""
"begin"
"execute immediate 'drop sequence wmsys.wm$up_del_trig_name_sequence' ; "
"exception when others then null;"
"end;"
""
"begin"
"execute immediate 'drop sequence wmsys.wm$insteadof_trigs_sequence' ; "
"exception when others then null;"
"end;"
""
"begin "
"execute immediate 'drop sequence wmsys.wm$lock_sequence' ; "
"exception when others then null;"
"end;"
""
"begin"
"execute immediate 'drop sequence wmsys.wm$vtid' ; "
"exception when others then null;"
"end;"
""
"begin"
"execute immediate 'drop sequence wmsys.wm$adt_sequence' ; "
"exception when others then null;"
"end;"
""
"begin"
"execute immediate 'drop sequence wmsys.wm$version_sequence' ; "
"exception when others then null;"
"end;"
""
"begin"
"execute immediate 'drop sequence wmsys.wm$row_sync_id_sequence' ; "
"exception when others then null;"
"end;"
""
"begin"
"execute immediate 'drop sequence wmsys.wm$udtrig_dispatcher_sequence' ; "
"exception when others then null;"
"end;"
""
"execute immediate 'create sequence wmsys.wm$up_del_trig_name_sequence start"
" with 3 nocache';"
"execute immediate 'create sequence wmsys.wm$insteadof_trigs_sequence start "
"with 3 nocache';"
"execute immediate 'create sequence wmsys.wm$lock_sequence start with 6 incr"
"ement by 2 nocache';"
"execute immediate 'create sequence wmsys.wm$vtid start with 3 nocache';"
"execute immediate 'create sequence wmsys.wm$adt_sequence start with 3 nocac"
"he';"
"execute immediate 'create sequence wmsys.wm$version_sequence start with 3 n"
"ocache';"
"execute immediate 'create sequence wmsys.wm$row_sync_id_sequence start with"
" 13 nocache';"
"execute immediate 'create sequence wmsys.wm$udtrig_dispatcher_sequence star"
"t with 3 nocache'; "
"END IF ;"
""
"COMMIT; END;"
IMP-00003: 遇到 ORACLE 错误 6550
ORA-06550: 第 21 行, 第 19 列:
PL/SQL: ORA-00942: 表或视图不存在
ORA-06550: 第 21 行, 第 1 列:
PL/SQL: SQL Statement ignored
ORA-06550: 第 26 行, 第 19 列:
PL/SQL: ORA-00942: 表或视图不存在
ORA-06550: 第 26 行, 第 1 列:
PL/SQL: SQL Statement ignored
ORA-06550: 第 31 行, 第 19 列:
PL/SQL: ORA-00942: 表或视图不存在
ORA-06550: 第 31 行, 第 1 列:
PL/SQL: SQL Statement ignored
这是由于匿名块中访问的表不存在造成的,于是,在删除用户时,忽略WMSYS用户,然后重新执行导入操作:
SQL> DECLARE
2 TYPE T_VARCHAR_TAB IS TABLE OF VARCHAR2(32767) INDEX BY BINARY_INTEGER;
3 V_DROP_STR T_VARCHAR_TAB;
4 V_CREATE_STR T_VARCHAR_TAB;
5 BEGIN
6 SELECT DBMS_METADATA.GET_DDL('USER', USERNAME) BULK COLLECT INTO V_CREATE_STR
7 FROM DBA_USERS
8 WHERE USERNAME NOT IN ('SYS', 'SYSTEM', 'DBSNMP', 'WMSYS');
9 SELECT 'DROP USER ' || USERNAME || ' CASCADE' BULK COLLECT INTO V_DROP_STR
10 FROM DBA_USERS
11 WHERE USERNAME NOT IN ('SYS', 'SYSTEM', 'DBSNMP', 'WMSYS');
12 FOR I IN 1..V_DROP_STR.COUNT LOOP
13 EXECUTE IMMEDIATE V_DROP_STR(I);
14 END LOOP;
15 FOR I IN 1..V_CREATE_STR.COUNT LOOP
16 EXECUTE IMMEDIATE V_CREATE_STR(I);
17 END LOOP;
18 END;
19 /
PL/SQL 过程已成功完成。
SQL> DROP PUBLIC SYNONYM GENREMOTETASKINTERRUPTEDEXCEPT;
同义词已删除。
SQL> DROP PUBLIC SYNONYM GENREMOTEOBJECTCLOSEDEXCEPTION;
同义词已删除。
SQL> DROP PUBLIC SYNONYM GENCONNECTIONPARAMETERINFOSEQU;
同义词已删除。
SQL> DROP PUBLIC SYNONYM GENREMOTEAUTHENTICATIONEXCEPTI;
同义词已删除。
SQL> DROP PUBLIC SYNONYM GENREMOTEAPIVERSIONMISMATCHEXC;
同义词已删除。
SQL> DROP PUBLIC SYNONYM GENMETADATAPROPERTYVALUESUNION;
同义词已删除。
SQL> DROP PUBLIC SYNONYM GENMETADATAPROPERTYBAGSEQUENCE;
同义词已删除。
SQL> DROP PUBLIC SYNONYM GENCONNECTIONPARAMETERINFOSTRU;
同义词已删除。
SQL> DROP PUBLIC SYNONYM GENCONNECTIONPARAMETERTYPEENUM;
同义词已删除。
SQL> DROP PUBLIC SYNONYM GENREMOTESPECIFICATIONUPDATENE;
同义词已删除。
SQL> DROP PUBLIC SYNONYM GENCOMPOUNDCURSORBLOCKSEQUENCE;
同义词已删除。
SQL> DROP PUBLIC SYNONYM GENPARENTSTARTENDBLOCKSEQUENCE;
同义词已删除。
SQL> DROP PUBLIC SYNONYM GENINVALIDINDEXSPECIFICATIONEX;
同义词已删除。
SQL> DROP PUBLIC SYNONYM GENINCLUDEDDEPENDENCYBLOCKSTRU;
同义词已删除。
SQL> DROP PUBLIC SYNONYM GENDEPENDENCYBLOCKSEQUENCESEQU;
同义词已删除。
SQL> DROP PUBLIC SYNONYM GENCURSORSPECIFIERSEQUENCESEQU;
同义词已删除。
SQL> DROP PUBLIC SYNONYM GENRECURSIVEJOINDEFINITIONSTRU;
同义词已删除。
SQL> DROP PUBLIC SYNONYM GENCONSTANTLISTDEFINITIONSTRUC;
同义词已删除。
SQL> DROP PUBLIC SYNONYM SQLREMOTETASKINTERRUPTEDEXCEPT;
同义词已删除。
SQL> DROP PUBLIC SYNONYM SQLMETADATAPROPERTYVALUESUNION;
同义词已删除。
SQL> DROP PUBLIC SYNONYM SQLMETADATAPROPERTYBAGSEQUENCE;
同义词已删除。
SQL> DROP PUBLIC SYNONYM SQLREMOTEAUTHENTICATIONEXCEPTI;
同义词已删除。
SQL> DROP PUBLIC SYNONYM SQLREMOTEAPIVERSIONMISMATCHEXC;
同义词已删除。
SQL> DROP PUBLIC SYNONYM SQLCONNECTIONPARAMETERINFOSEQU;
同义词已删除。
SQL> DROP PUBLIC SYNONYM SQLCONNECTIONPARAMETERTYPEENUM;
同义词已删除。
SQL> DROP PUBLIC SYNONYM SQLCONNECTIONPARAMETERINFOSTRU;
同义词已删除。
SQL> DROP PUBLIC SYNONYM SQLPARENTSTARTENDBLOCKSEQUENCE;
同义词已删除。
SQL> DROP PUBLIC SYNONYM SQLINCLUDEDDEPENDENCYBLOCKSTRU;
同义词已删除。
SQL> DROP PUBLIC SYNONYM SQLREMOTESPECIFICATIONUPDATENE;
同义词已删除。
SQL> DROP PUBLIC SYNONYM SQLINVALIDINDEXSPECIFICATIONEX;
同义词已删除。
SQL> DROP PUBLIC SYNONYM SQLDEPENDENCYBLOCKSEQUENCESEQU;
同义词已删除。
SQL> DROP PUBLIC SYNONYM SQLCOMPOUNDCURSORBLOCKSEQUENCE;
同义词已删除。
SQL> DROP PUBLIC SYNONYM SQLCONSTANTLISTDEFINITIONSTRUC;
同义词已删除。
导入完成后,发现ORA-错误77个,IMP-错误312个。
忽略了WMSYS用户果然有效,但是由于数据没有清除干净,在导入的时候报了唯一约束冲突的错误,于是修改删除SYSTEM用户数据的匿名块,使之同时删除WMSYS用户下的数据。同时注意到SYSTEM表中由于存在很多“ORA-02264: 名称已被一现有约束条件占用”的错误,于是通过匿名块删除这些重复的错误。
SQL> SET SERVEROUT ON
SQL> DECLARE
2 V_CNT NUMBER := 0;
3 V_DEL NUMBER := 0;
4 V_LOOP NUMBER := 0;
5 V_RESULT NUMBER := 0;
6 BEGIN
7 <<LABLE_FOR_LOOP>>
8 FOR I IN (SELECT OWNER || '.' || TABLE_NAME TABLE_NAME FROM DBA_TABLES WHERE OWNER IN ('SYSTEM
', 'WMSYS')) LOOP
9 EXECUTE IMMEDIATE 'SELECT COUNT(*) FROM ' || I.TABLE_NAME INTO V_RESULT;
10 IF V_RESULT != 0 THEN
11 BEGIN
12 V_CNT := V_CNT + 1;
13 EXECUTE IMMEDIATE 'DELETE ' || I.TABLE_NAME;
14 V_DEL := V_DEL + 1;
15 EXCEPTION
16 WHEN OTHERS THEN
17 NULL;
18 END;
19 END IF;
20 END LOOP;
21 V_LOOP := V_LOOP + 1;
22 DBMS_OUTPUT.PUT_LINE(V_LOOP || ':' || ' COUNT ' || V_CNT || ', DEL ' || V_DEL);
23 IF V_CNT != V_DEL THEN
24 V_CNT := 0;
25 V_DEL := 0;
26 GOTO LABLE_FOR_LOOP;
27 END IF;
28 END;
29 /
1: COUNT 14, DEL 14
PL/SQL 过程已成功完成。
SQL> COMMIT;
提交完成。
SQL> BEGIN
2 FOR I IN (SELECT 'ALTER TABLE ' || OWNER || '.' || TABLE_NAME || ' DROP CONSTRAINT ' || CONSTR
AINT_NAME DROP_CONS
3 FROM DBA_CONSTRAINTS
4 WHERE OWNER = 'SYSTEM'
5 AND CONSTRAINT_NAME NOT LIKE 'SYS%'
6 AND CONSTRAINT_TYPE = 'C')
7 LOOP
8
9 EXECUTE IMMEDIATE I.DROP_CONS;
10 END LOOP;
11 END;
12 /
PL/SQL 过程已成功完成。
导入后发现ORA错误还有47个,IMP错误252个。