impdp导入错误:
错误1
impdp *****/*** directory=DATA_PUMP_DIR dumpfile=scott_%U.dmp logfile=scott.log parallel=2
ORA-31693: Table data object "NC65"."PUB_WORKINGTASKLOG" failed to load/unload and is being skipped due to error:
ORA-39155: error expanding dump file name "/backup/scott_01.dmp.dmp"
ORA-48128: opening of a symbolic link is disallowed
ORA-19505: failed to identify file "/backup/scott_01.dmp.dmp"
ORA-27037: unable to obtain file status
在rac环境中使用并行时要设置cluster=N或者不加并行。
错误2
impdp *****/***@pdb dumpfile=Exp****.DMP logfile=impdp_pdb.log directory=test;
Connected to: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
ORA-39001: invalid argument value
ORA-39000: bad dump file specification
ORA-31640: unable to open dump file "/backup/scott_01.dmp.dmp" for read
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 7
lsnrctl status检查PDB监听状态确保监听连接正常。
错误3
ORA-39000: bad dump file specification
ORA-31640: unable to open dump file "/backup/scott_01.dmp.dmp" for read
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
directory目录问题,重新创建目录并授权
SQL> drop directory DATA_PUMP_DIR;
SQL> create directory DATA_PUMP_DIR as '/backup/';
SQL> grant read, write on directory expdp_dir to system, scott,sys;
错误4
impdp scott/oracle directory=data_pump_dir dumpfile=scott_%u.dmp logfile=scott.log parallel=2 table_exists_action=truncate
ORA-31693: Table data object <TABLENAME> failed to load/unload and is being skipped due to error:
ORA-29913: error in executing ODCIEXTTABLEOPEN callout
12c可能遇到,重新执行或使用table_exists_action=replace
错误5
...
Processing object type DATABASE_EXPORT/NORMAL_OPTIONS/VIEWS_AS_TABLES/TABLE_DATA
ORA-31693: Table data object "SYSTEM"."SCHEDULER_PROGRAM_ARGS_TMP" failed to load/unload and is being skipped due to error:
ORA-29913: error in executing ODCIEXTTABLEFETCH callout
ORA-22303: type "SYS"."JDM_STR_VALS" not found
ORA-21700: object does not exist or is marked for delete
...
目标端不存在JDM_STR_VALS:
select owner, object_name, object_type, status
from dba_objects
where owner = 'SYS'
and object_name = 'JDM_STR_VALS';
在相同版本库中导出JDM_STR_VALS并在目标库执行:
set pagesize 999
set linesize 100
set long 99999
select dbms_metadata.get_ddl('TYPE','JDM_STR_VALS','SYS') from dual;
错误6
Import: Release 12.1.0.2.0 - Production on Sat Mar 28 00:00:59 2020
Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
Primary table "SYS"."SYS_IMPORT_TABLE_01" successfully loaded/unloaded
Starting "SYS"."SYS_IMPORT_TABLE_01": /******** AS SYSDBA parfile=table.par
Processing object type TABLE_EXPORT/TABLE/TABLE
ORA-39083: Object type TABLE:"OWNER"."TABLE_NAME" failed to create with error:
ORA-01849: hour must be between 1 and 12
Failing sql is:
CREATE TABLE "OWNER"."TABLE_NAME" (...,"XXX" DATE DEFAULT to_timestamp(sysdate,'DD-MON-RR HH.MI.SSXFF AM'))
NLS设置不一致:
Source
-----------
PARAMETER VALUE
------------------------------ -----------------------------------
NLS_LANGUAGE ENGLISH >>>>>>>>>>>>>>>>>>>>>>>>>>
NLS_TERRITORY UNITED KINGDOM >>>>>>>>>>>>>>
Target
-----------
PARAMETER VALUE
------------------------------ ------------------------------
NLS_LANGUAGE AMERICAN >>>>>>>>>>>>>>>>>
NLS_TERRITORY AMERICA >>>>>>>>>>>>>>>>>
export NLS_LANG=<set as Source >;
错误7
ORA-39002: invalid operation
ORA-31694: master table "SYSTEM"."SYS_IMPORT_SCHEMA_02" failed to load/unload
ORA-02354: error in exporting/importing data
ORA-39773: parse of metadata stream failed
文件不完整
错误8
ORA-39001: invalid argument value
ORA-39000: bad dump file specification
ORA-39142: incompatible version number 3.1 in dump file "/.../.../.....dmp"
也可能是
ORA-31619: invalid dump file "/.../.../.....dmp"
dmp文件的版本与数据库版本不匹配,低版本的dmp文件导入高版本的数据库没有问题,反之则不行。
解决办法:在导出时加version=目标数据库版本,需要注意的是,dmp文件的版本与客户端也有密切的关系,如果使用exp导出时,以exp的版本为基准,如db[11g]-->client[12c]--->dmp文件[12c]
expdp导出错误
错误1
ORA-31693: Table data object "APP"."TAB_CHAT_INFO" failed to load/unload and is being skipped due to error:
ORA-02354: error in exporting/importing data
ORA-01555: snapshot too old: rollback segment number 3 with name "_SYSSMU3_759247292$" too small
导出表中有LOB字段,undo保留时间不足
alter system set undo_retention = 3600 scope=both;
错误2
expdp directory=DATA_PUMP_DIR schemas=app dumpfile=app.dmp logfile=app.log parallel=2
ORA-31693: Table data object "APP"."COUNTRIES" failed to load/unload and is being skipped due to error:
ORA-31617: unable to open dump file "/backup/app.dmp" for write
ORA-19505: failed to identify file "/backup/app.dmp"
ORA-27037: unable to obtain file status
SVR4 Error: 2: No such file or directory
rac环境导出使用并行需要加CLUSTER=N
错误3
UDE-31623: operation generated ORACLE error 31623
ORA-31623: a job is not attached to this session via the specified handle
ORA-06512: at "SYS.DBMS_DATAPUMP", line 3263
ORA-06512: at "SYS.DBMS_DATAPUMP", line 4488
ORA-06512: at line 1
修改streams_pool_size大小
alter system set streams_pool_size=48m
错误4
ORA-39002: invalid operation
dbms_datapump.get_status(178...)
ORA-39002: invalid operation
ORA-39070: unable to open the log file.
ORA-29283: invalid file opertion
ORA-06512: at "SYS.UTL_FILE", line 536
ORA-29283: invalid file operation
DATAPUMP目录权限不正确
选项
INCLUDE
and EXCLUDE
可用于导出和导入两个命令中,通常的用法如下:
语法
INCLUDE/EXCLUDE=object_type[:name_clause] [, ...]
object_type指SEQUENCE,VIEW,TABLE,INDEX,PACKAGE等
可以从DATABASE_EXPORT_OBJECTS/SCHEMA_EXPORT_OBJECTS/TABLE_EXPORT_OBJECTS中的OBJECT_PATH列获取对象类型。
name_clause是一个sql表达式,必须用冒号与对象类型分开,并用双引号括起来,同时需要用单引号来分隔名称字符串。
例如,EXCLUDE=INDEX:"LIKE 'EMP%'"
示例
### 实际使用过程中需要注意转义
EXCLUDE=FUNCTION
EXCLUDE=PROCEDURE
EXCLUDE=PACKAGE
EXCLUDE=INDEX:\"LIKE \'EMP%\' \"
EXCLUDE=TABLE:\"IN \(\'EMP\',\'DEPT\'\)\"
EXCLUDE=INDEX:\"= \'INDX_NAME\'\"
EXCLUDE=SEQUENCE,VIEW,TABLE:\"IN \(\'EMP\',\'DEPT\'\)\"
Starting with Oracle Database 21c, Oracle Data Pump permits you to set both INCLUDE
and EXCLUDE
parameters in the same command. When you include both parameters in a command, Oracle Data Pump processes the INCLUDE
parameter first, and includes all objects identified by the parameter. Then it processes the exclude parameters, eliminating the excluded objects from the included set.
---21c开始支持include和exlude同时使用,include优先。
其他
---导出package
expdp app/oracle directory=DATA_PUMP_DIR dumpfile=dmon.dmp logfile=dbmon.log INCLUDE=PACKAGE
---生成sql
impdp app/oracle directory=DATA_PUMP_DIR dumpfile=dmon.dmp sqlfile=dmon.sql
---正常导出
expdp system/oracle directory=DATA_PUMP_DIR dumpfile=dmon.dmp logfile=dbmon.log schemas=dbmon
******************************************************************************
. . exported "DBMON"."EBA_DEMO_TREE_PROJECTS" 10.29 KB 9 rows
. . exported "DBMON"."EBA_DEMO_TREE_PROJ_FILES" 50.34 KB 4 rows
. . exported "DBMON"."EBA_DEMO_TREE_SUBTASK" 13.05 KB 18 rows
. . exported "DBMON"."EBA_DEMO_TREE_TASK" 11.28 KB 6 rows
. . exported "DBMON"."EBA_DEMO_TREE_DEPT" 5.953 KB 4 rows
. . exported "DBMON"."EBA_DEMO_TREE_EMP" 8.585 KB 14 rows
. . exported "DBMON"."EBA_DEMO_TREE_POPULATION" 12.22 KB 51 rows
. . exported "DBMON"."EBA_DEMO_TREE_STOCKS" 10.95 KB 11 rows
. . exported "DBMON"."SYS_EXPORT_SCHEMA_01" 5.828 KB 14 rows
. . exported "DBMON"."SYS_EXPORT_SCHEMA_02" 5.859 KB 15 rows
. . exported "DBMON"."SYS_EXPORT_SCHEMA_03" 5.890 KB 16 rows
. . exported "DBMON"."USERS" 11.14 KB 2 rows
. . exported "DBMON"."tab_users" 0 KB 0 rows
Master table "SYSTEM"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
---排除SYS_EXPORT_SCHEMA*导入
impdp system/oracle directory=DATA_PUMP_DIR dumpfile=dmon.dmp logfile=dbmon.log remap_schema=dbmon:scott exclude=table:\"like \'%SYS_EXPORT_SCHEMA_%\'\"
.....
. . imported "SCOTT"."EBA_DEMO_TREE_PROJECTS" 10.29 KB 9 rows
. . imported "SCOTT"."EBA_DEMO_TREE_PROJ_FILES" 50.34 KB 4 rows
. . imported "SCOTT"."EBA_DEMO_TREE_SUBTASK" 13.05 KB 18 rows
. . imported "SCOTT"."EBA_DEMO_TREE_TASK" 11.28 KB 6 rows
. . imported "SCOTT"."EBA_DEMO_TREE_DEPT" 5.953 KB 4 rows
. . imported "SCOTT"."EBA_DEMO_TREE_EMP" 8.585 KB 14 rows
. . imported "SCOTT"."EBA_DEMO_TREE_POPULATION" 12.22 KB 51 rows
. . imported "SCOTT"."EBA_DEMO_TREE_STOCKS" 10.95 KB 11 rows
. . imported "SCOTT"."USERS" 11.14 KB 2 rows
. . imported "SCOTT"."tab_users" 0 KB 0 rows
Processing object type SCHEMA_EXPORT/FUNCTION/FUNCTION