使用expdp/impdp导出导入数据时,遇到ORA-2000错误,如下所示:- Processing object type SCHEMA_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT
- Processing object type SCHEMA_EXPORT/TABLE/COMMENT
- Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
- Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
- Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
- Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
- Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
- Processing object type SCHEMA_EXPORT/STATISTICS/MARKER
- xxxx.xxxxx : sqlerrm = ORA-20000: Unable to set values for index xxx: does not exist or insufficient privileges
- Importing statistics failed for 1 object(s);
复制代码 导出环境为Oracle 12c,导入的数据库环境为Oracle 19c,具体版本为19.16.0.0.0,查了一下Oracle Support,刚好是遇到了Bug 30978304,关于为什么会出现这个错误,ORA-20000 from Data Pump Import (IMPDP) when PK Constraint does not Create a New Index (Doc ID 2679433.1)[1]中,有详细的案例描述,这里就没有必要自己再构造一个案例来描述出现ORA-20000错误的场景,具体如下所示:- APPLIES TO:
- Oracle Database - Enterprise Edition - Version 19.1.0.0.0 and later
- Information in this document applies to any platform.
- SYMPTOMS
- While running Data Pump Import (IMPDP) with STATISTICS, the order of creating indexes and constraints allowed a primary key constraint to reference a user created index rather than creating a new index as it should.
-
- A simplified test case:
- SQL> drop user INDEXTEST cascade;
- SQL> create user INDEXTEST identified by INDEXTEST;
- SQL> grant dba to INDEXTEST;
- SQL> connect INDEXTEST/INDEXTEST
- SQL> create table i_test (id number, t1 varchar2(100), t2 varchar2(100));
- SQL> alter table i_test add constraint i_test_pk primary key (id, t1, t2);
- SQL> insert into i_test values (1,1,1);
- SQL> commit;
- SQL> create unique index i_test_idx on i_test(id, t2, t1);
- SQL> select index_name from user_indexes;
- SQL> select constraint_name from user_constraints;
- SQL> EXEC DBMS_STATS.GATHER_SCHEMA_STATS('INDEXTEST');
- SQL> !expdp system/<Password> schemas=INDEXTEST dumpfile=INDEXTEST reuse_dumpfiles=y
- SQL> connect system/<Password>
- SQL> drop user INDEXTEST cascade;
- SQL> !impdp system/<Password> schemas=INDEXTEST dumpfile=INDEXTEST
- Import: Release 19.0.0.0.0 - Production on Mon Mar 2 19:08:53 2020 Version 19.3.0.0.0
- Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
- Connected to: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
- Master table "SYSTEM"."SYS_IMPORT_SCHEMA_01" successfully loaded/unloaded
- Starting "SYSTEM"."SYS_IMPORT_SCHEMA_01": system/******** schemas=INDEXTEST
- dumpfile=INDEXTEST
- Processing object type SCHEMA_EXPORT/USER
- Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
- Processing object type SCHEMA_EXPORT/ROLE_GRANT
- Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
- Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
- Processing object type SCHEMA_EXPORT/TABLE/TABLE
- Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
- . . imported "INDEXTEST"."I_TEST" 5.898 KB 1 rows
- Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
- Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
- Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
- Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
- Processing object type SCHEMA_EXPORT/STATISTICS/MARKER
- INDEXTEST.I_TEST_PK : sqlerrm = ORA-20000: Unable to set values for index I_TEST_PK: does not exist or insufficient privileges Importing statistics failed for 1 object(s);
- Job "SYSTEM"."SYS_IMPORT_SCHEMA_01" completed with 2 error(s) at Mon Mar 2
- 19:09:13 2020 elapsed 0 00:00:19
- SQL> connect INDEXTEST/INDEXTEST
- SQL> select index_name from user_indexes;
- SQL> select constraint_name from user_constraints;
- SQL> exit;
-
- Note: It was reported that this issue also exists when the column order is the same, but the user created index has an extra column.
-
- CHANGES
- The database was upgraded to 19c release or higher. The issue did not reproduce in 12.2 or 18c environments.
-
- CAUSE
- This issue is caused by a product defect.
- It was investigated in:
- unpublished Bug 30978304 - ORA-20000 DURING IMPDP WITH STATS AND THE UNIQUE INDEX FOR THE PK IS NOT CREATED
- Reference:
- Bug 30978304 - ORA-20000 During Data Pump Import While Importing Statistics (Document 30978304.8)
复制代码 Bug 30978304 - ORA-20000 During Data Pump Import While Importing Statistics (Doc ID 30978304.8)[2]影响的版本还蛮多的,如下截图所示
Bug 30978304的详细描述如下所示:- Description
- ORA-20000 error was occurring with Data Pump importing statistics, with certain combinations of indexes.
- This has now been fixed.
-
- What Happens?
-
- After importing a transportable tablespace, extents belonging to an index are
- incorrectly marked as unallocated in the tablespace bitmaps. This leads to
- objd mismatch asserts because such extents could eventually be allocated to
- another object.
-
- Conditions
-
- The export-side must have the following properties:
-
- There is a user-created table with a multi-column PK constraint in the table
- DDL. This constraint has a system-generated unique index (say ABC).
- There is a user-created unique index (say XYZ) on the same columns as the PK,
- but the column ordering differs.
- Note that if the column ordering matches, XYZ creation would have failed with
- ORA-1408 and this bug wont occur.
-
- Fix
-
- The fix forces the creation of ABC earlier. This resolves the corruption
-
- REDISCOVERY INFORMATION:
-
- ORA-20000 occurring while impdp is importing statistics, when two or more indexes exist on a table and
- one of them is a primary key index.
-
- Additional symptoms:
-
- TTS import from a 12.1 DB to 19c corrupts the Tablespace bitmaps which can
- result in the following errors being raised for operations on segments
- belonging to the Tablespace :
-
- 1. ORA-8103
- 2. ORA-600 [kcl_mismatch_1]
- 3. ORA-600 [kdifind:kcbz_objdchk]
- 4. ORA-600 [ktrget2:kcbz_objdchk]
- 5. ORA-600 [ktspffbmb:objdchk_kcbnew_3]
- 6. ORA-600 [ktspgtb2:kcbz_objdchk]
-
- Workaround
- None.
-
- You can likely get this fix in:
- Data Pump Recommended Proactive Patches For 19.10 and Above (Doc ID 2819284.1)
复制代码 这里记录一下今天遇到的案例,了解一下问题的来龙去脉。
参考资料
[1] : https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrl-state=g9qrlq9os_4&_afrLoop=203438157763988
[2] : https://support.oracle.com/epmos/faces/SearchDocDisplay?_afrLoop=211126172370682&_afrWindowMode=0&_adf.ctrl-state=iqtartzdc_4
扫描上面二维码关注我如果你真心觉得文章写得不错,而且对你有所帮助,那就不妨帮忙“推荐"一下,您的“推荐”和”打赏“将是我最大的写作动力!本文版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接.
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作! |