oracle 11g impdp返回无效操作且未找到对象

时间:2018-07-25 13:01:07

标签: oracle oracle11g database-table impdp expdp

我想使用expdpimpdp命令在两个用户之间传输oracle表。

首先,我创建了一个目录并为源用户和目标用户授予了适当的特权:

SQL> CREATE OR REPLACE DIRECTORY TEST_DIR AS '/u01/app/oracle/oradata/temp_dirs';
Directory created.
SQL> GRANT READ, WRITE ON DIRECTORY test_dir TO SOURCE_USER;
Grant succeeded.
SQL> GRANT READ, WRITE ON DIRECTORY test_dir TO DEST_USER;
Grant succeeded.
SQL> commit;

这是我的expdp命令,它的输出是:

oracle@lab-57:~$ expdp SOURCE_USER/SOURCE_USER tables=tbl_user directory=TEST_DIR dumpfile=users.dmp logfile=exp_users.log 

Export: Release 11.2.0.1.0 - Production on Tue Jul 24 16:18:27 2018

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "SOURCE_USER"."SYS_EXPORT_TABLE_01":  SOURCE_USER/******** tables=tbl_user directory=TEST_DIR dumpfile=users.dmp logfile=exp_users.log 
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 64 KB
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . exported "SOURCE_USER"."TBL_USER"                        8.085 KB       2 rows
Master table "SOURCE_USER"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SOURCE_USER.SYS_EXPORT_TABLE_01 is:
  /u01/app/oracle/oradata/temp_dirs/users.dmp
Job "SOURCE_USER"."SYS_EXPORT_TABLE_01" successfully completed at 16:18:38

这意味着导出操作已成功完成。

然后我尝试使用impdp导入它,如下所示:

oracle@lab-57:~$ impdp DEST_USER/DEST_USER tables=TBL_USER directory=TEST_DIR dumpfile=users.dmp logfile=imp_users.log

Import: Release 11.2.0.1.0 - Production on Tue Jul 24 17:26:58 2018

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
ORA-39002: invalid operation
ORA-39166: Object DEST_USER.TBL_USER was not found.

我还尝试了tables=DEST_USER.TBL_USERcontent=data_only;都返回相同的错误。

2 个答案:

答案 0 :(得分:0)

当您导出为SOURCE_USER并导入为DEST_USER时,REMAP_SCHEMA参数可能会有所帮助。 (我将命令分成几行以便于阅读)

impdp DEST_USER/DEST_USER tables=TBL_USER directory=TEST_DIR 
dumpfile=users.dmp logfile=imp_users.log
remap_schema=source_user:dest_user             --> this

如果您使用的是11.2,则可能会遇到一个错误,该错误将不允许您执行此操作(有关更多信息,请参见My Oracle Support)。在这种情况下,您仍然可以执行导入,但是必须省略TABLES参数,即

                          TABLES was in this gap
                                 |
impdp DEST_USER/DEST_USER        v       directory=TEST_DIR 
dumpfile=users.dmp logfile=imp_users.log
remap_schema=source_user:dest_user

答案 1 :(得分:0)

简单答案:

创建导入:准备好转储。

还原转储的两个选项,考虑完整转储或特定表。

针对特定表:-表名称= MONTHS_DAY

impdp DBA_USER/DBA_Password tables = SOURCE_SCHEMA.MONTHS_DAY directory=AKSHAY_SPM_EDIR dumpfile=MONTHS_DAY.dmp logfile=impdpMONTHS_DAY.log remap_schema = SOURCE_SCHEMA:DESTINATION_SCHEMA

完整导入:

impdp DBA_USER/DBA_Password directory = AKSHAY_SPM_EDIR dumpfile=MONTHS_DAY.dmp logfile=impdpMONTHS_DAY.log remap_schema = SOURCE_SCHEMA:DESTINATION_SCHEMA

请确保目录可以访问,因为那里存在转储