IMPDP - ORA-39083 ORA-01917 (user or role does not exist) Errors On A Schema Or Table or Tablespace Level Import Data Pump Job (Doc ID 1916469.1)

IMPDP - ORA-39083 ORA-01917 (user or role does not exist) Errors On A Schema Or Table or Tablespace Level Import Data Pump Job (Doc ID 1916469.1)

In this Document

  Symptoms
  Changes
  Cause
  Solution
  References

APPLIES TO:

Oracle Database - Enterprise Edition - Version 10.1.0.2 to 12.2.0.1 [Release 10.1 to 12.2]
Oracle Database - Standard Edition - Version 10.1.0.2 to 12.2.0.1 [Release 10.1 to 12.2]
Oracle Database - Personal Edition - Version 10.1.0.2 to 12.2.0.1 [Release 10.1 to 12.2]
Enterprise Manager for Oracle Database - Version 10.1.0.2 to 13.1.2.0.0 [Release 10.1 to 13.1]
Information in this document applies to any platform.
***Checked for relevance on 26-Feb-2016***

SYMPTOMS

1.  You created a schema with grants to other users or roles, e.g.:

connect / as sysdba

-- create a role:
create role my_role;

-- create test schema's
create user tc identified by tc default tablespace users
   temporary tablespace temp;
alter user tc quota unlimited on users;
grant create session, create table, create role to tc;

create user tc2 identified by tc default tablespace users
   temporary tablespace temp;
alter user tc2 quota unlimited on users;
grant create session, create table to tc2;

-- create a test table and grants:
connect tc/tc
create table tc.my_tab (nr number, txt varchar2(10));
grant select on my_tab to tc2;
grant insert on my_tab to my_role;

connect / as sysdba

2. You want to move the schema to a different database and you export the schema with Export Data Pump, e.g.:

$ expdp system/manager directory=my_dir dumpfile=expdp_tc.dmp logfile=expdp_tc.log reuse_dumpfiles=y schemas=tc

Export: Release 11.2.0.4.0 - Production on Tue Aug 12 15:07:39 2014
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
FLASHBACK automatically enabled to preserve database integrity.
Starting "SYSTEM"."SYS_EXPORT_SCHEMA_01":  system/******** directory=my_dir dumpfile=expdp_tc.dmp logfile=expdp_tc.log reuse_dumpfiles=y schemas=tc
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 0 KB
Processing object type SCHEMA_EXPORT/USER
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/TABLESPACE_QUOTA
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT
. . exported "TC"."MY_TAB"                                   0 KB       0 rows
Master table "SYSTEM"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYSTEM.SYS_EXPORT_SCHEMA_01 is:
  /u01/expdp/EXPDP_TC.DMP
Job "SYSTEM"."SYS_EXPORT_SCHEMA_01" successfully completed at Tue Aug 12 15:07:50 2014 elapsed 0 00:00:09

3. You import the schema with Import Data Pump, but the following errors are seen:

$ impdp system/manager directory=my_dir dumpfile=expdp_tc.dmp logfile=impdp_tc.log schemas=tc

Import: Release 11.2.0.4.0 - Production on Tue Aug 12 15:29:00 2014
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table "SYSTEM"."SYS_IMPORT_SCHEMA_01" successfully loaded/unloaded
Starting "SYSTEM"."SYS_IMPORT_SCHEMA_01":  system/******** directory=my_dir dumpfile=expdp_tc.dmp logfile=impdp_tc.log schemas=tc
Processing object type SCHEMA_EXPORT/USER
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/TABLESPACE_QUOTA
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 "TC"."MY_TAB"                                   0 KB       0 rows
Processing object type SCHEMA_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT
ORA-39083: Object type OBJECT_GRANT failed to create with error:
ORA-01917: user or role 'MY_ROLE' does not exist
Failing sql is:
GRANT INSERT ON "TC"."MY_TAB" TO "MY_ROLE"
ORA-39083: Object type OBJECT_GRANT failed to create with error:
ORA-01917: user or role 'TC2' does not exist
Failing sql is:
GRANT SELECT ON "TC"."MY_TAB" TO "TC2"
Job "SYSTEM"."SYS_IMPORT_SCHEMA_01" completed with 2 error(s) at Tue Aug 12 15:29:04 2014 elapsed 0 00:00:02

CHANGES

CAUSE

1.  Errors such as:

ORA-39083: Object type OBJECT_GRANT failed to create with error:
ORA-01917: user or role 'TC2' does not exist

are reported during an Import Data Pump because a schema (TC) was exported, which had objects with grants to other users or roles (like TC2 or MY_ROLE).
In the target database, those users or roles did not exist, and as a result the import fails to grant privileges to those non-existing users or roles.

2. This problem also reproduces for TABLE level Export DataPump jobs (TABLES=...), or TABLESPACE level (TABLESPACES=...), or TRANSPORT_TABLESPACE level jobs (TRANSPORT_TABLESPACES=...).

SOLUTION

1. Ignore those errors after confirming that these missing grants do not impact what you want to achieve with the import.

- OR -

2. Also import the missing schemas's and roles into the target database and then re-import the grants, e.g.:

-- on the source database, run another Export Data Pump job, and export the users and/or roles that were reported in the errors of the earlier import Data Pump job:
$ expdp system/manager directory=my_dir dumpfile=expdp_users.dmp logfile=expdp_users.log reuse_dumpfiles=y full=y include=user:\"in(\'TC2\', \'MY_ROLE\')\" include=role:\"in(\'TC2\', \'MY_ROLE\')\"

-- on the target database, import these users and roles:
$ impdp system/manager directory=my_dir dumpfile=expdp_users.dmp logfile=impdp_users.log full=y

-- on the target database, re-run an import of the grants:
$ impdp system/manager directory=my_dir dumpfile=expdp_tc.dmp logfile=impdp_tc.log schemas=tc include=grant


- OR -

2. Alternatively you can avoid the errors by ensuring that the schema's and roles also exist in the target database before the import starts, e.g.:

-- on the source database, export the schema you want to move:
$ expdp system/manager directory=my_dir dumpfile=expdp_tc.dmp logfile=expdp_tc.log reuse_dumpfiles=y schemas=tc

-- on the source database, export the users and/or roles that have grants on objects owned by TC:
$ expdp system/manager directory=my_dir dumpfile=expdp_users.dmp logfile=expdp_users.log reuse_dumpfiles=y full=y include=user:\"in(\'TC2\', \'MY_ROLE\')\" include=role:\"in(\'TC2\', \'MY_ROLE\')\"

-- on the target database, import these users and roles:
$ impdp system/manager directory=my_dir dumpfile=expdp_users.dmp logfile=impdp_users.log full=y

-- on the target database, import the schema you want to move:
$ impdp system/manager directory=my_dir dumpfile=expdp_tc.dmp logfile=impdp_tc.log schemas=tc


- OR -

4. Alternatively you can avoid the errors by excluding all object GRANTS during the Export or Import Data Pump job, e.g.:

$ impdp system/manager directory=my_dir dumpfile=expdp_tc.dmp logfile=impdp_tc.log schemas=tc exclude=grant

Note that this will exclude ALL grants, also grants on objects owned by TC to users or roles that do exist in the target database.

猜你喜欢

转载自www.cnblogs.com/chendian0/p/10867504.html