imp/impdp

来源:互联网 发布:shadowrocket 知乎 编辑:程序博客网 时间:2024/05/17 02:45

----------------------------------------------------10g以后的版本可使用impdp,使用步骤如下---------------------------------------------------------

SQL>
create directory imp_20130129 as '/opt/imp_shell';                          --/opt/imp_shell下放的是dmp文件,imp_20130129是建的一个虚拟的路径
grant read,write on directory imp_20130129 to system;                   --给路径赋权限   用system用户进行操作(sys和system的分工不同的),  对system进行授权,要使用超级管理员sqlplus / as sysdba

oracle用户下:
impdp system/system directory=imp_20130129 dumpfile=dump_schemas_10Jan2013_common_IM_DICT_INTUNIT_QUERY.dmp full=y logfile=common_IM_DICT_INTUNIT_QUERY.log table_exists_action=truncate                                                               ---帮助的话,使用imp -help了解参数

----------------------------------------------------数据导入过程中遇到的问题-------------------------------------------------------------------------

p570flpar3:/opt/imp_shell$impdp system/system directory=imp_20130129 dumpfile=crm_dump_11Jan2013_IM_tables.dmp full=y logfile=im.log table_exists_action=truncate

Import: Release 11.1.0.7.0 - 64bit Production on Tuesday, 29 January, 2013 14:52:05

Copyright (c) 2003, 2007, Oracle.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
ORA-39001: invalid argument value
ORA-39000: bad dump file specification
ORA-39142: incompatible version number 3.1 in dump file "/opt/imp_shell/crm_dump_11Jan2013_IM_tables.dmp"
错误原因:数据库版本的问题
p570flpar3:/opt/imp_shell$oerr ora 39142
39142, 00000, "incompatible version number %s in dump file \"%s\""
// *Cause:  A dump file was specified for an import operation whose version
//          number is incompatible with the dump file version of the
//          Data Pump product currently running on the system. Usually this
//          message indicates that the dump file was produced by a newer
//          version of the Data Pump export utility.
// *Action: Import this dump file using the Data Pump import utility with
//          the same version as the export which created the file.
p570flpar3:/opt/imp_shell$

http://frank1998819.iteye.com/blog/1750931----impdp问题

 

oracle10g的表导入到11g中:
在导出的时候加个version=你数据库的版本号
impdp user/password@db  DIRECTORY=dmpdir(查当前数据库的DMP文件名称) DUMPFILE=data.dmp version=数据库版本号
expdp user/password@db  DIRECTORY=dmpdir(查当前数据库的DMP文件名称) DUMPFILE=data.dmp version=数据库版本号

--注意:
只能从10g中导入到11g中,而无法从11g中导入到10g中,这是因为版本的问题,高版本会向下兼容,低版本不会向上兼容

-------------------------------------------------在dmp数据导入时,要注意以下问题--------------------------------------------------------------------------------

1、先看你要目标数据库与备份的版本差异(此类问题解决的是导入版本出错问题)
2、是怎么备份出来的(是exp备出的,还是数据泵备出的)
2、备份出来的数据的用户名
3、了解备份是有分区表的还是没有分区表的,有分区表的先建立分区表空间。
4、看数据量大不大,如果大的话要先建立大表的结构,这样导入速度快。
5、先按照先前的表空间建立数据库。
6、建立完成导入(开始->运行->输入cmd imp 用户名/密码 fromuser=备份出来的用户名 touser=用户名 file=路径\备份.dmp log=路径\日志名.log buffer=4096000 ignore=y commit=y  feedback=10000)
-----------------------------------------------------------------用法示例-------------------------------------------------------------

--expdp system/system schemas=YY0A directory=exp_20130311 dumpfile=yy0a.dmp logfile=yy0a.log;

---impdp system/system directory=imp_20130129 dumpfile=common_IM_DICT_INTUNIT_QUERY_20130201.dmp full=y logfile=common_IM_DICT_INTUNIT_QUERY.log table_exists_action=truncate


--exp yy0a/yy0a@orcl  file=dbbase.dmp       owner=dbbase     indexes=y statistics=none   rows=y  compress=y grants=y direct=y buffer=10240000 log=dbbase.log
--imp system/system file=./crm_dump_10Jan2013_yy0a_tables.dmp log=./dump_10Jan2013_yy0a_tables.log full=y ignore=y

0 0