oracle数据导入导出dmp文件
exp/imp 导入导出数据文件 (传统导出导入)
exp bto_c2/oss@orcl file=bto_c2_0903_tmp.dmp tables=categorydtl,seriesdtl log=bto_c2_0903_tmp.log
imp bto_c2_nm/oss@orcl file=bto_c2_0903_tmp.dmp tables=categorydtl,seriesdtl ignore=y log=bto_c2_0903_tmp.log
不需要其他操作,只需要在服务器Oracle用户下执行命令即可
expdp /impdp 导入导出数据文件(数据泵导出导入)
expdp bto_c2/oss@orcl directory=dump_dir dumpfile=nm_bto_c2.dmp logfile=nm_bto_c2_dmp.log tables=bto_c2.categorydtl,bto_c2.seriesdtl
impdp bto_c2_nm/oss@orcl DIRECTORY=dump_dir DUMPFILE=nm_bto_c2.dmp logfile=nm_bto_c2.log tables=bto_c2.categorydtl,bto_c2.seriesdtl REMAP_SCHEMA = bto_c2:bto_c2_nm;
参数说明:
directory=dump_dir 文件地址的一个指向(必须有)
tables=bto_c2.categorydtl,bto_c2.seriesdtl (当只需要导部分表的时候才加上这个参数,当导全部表时不需要)
REMAP_SCHEMA = bto_c2:bto_c2_nm (如果用户未变化,可以不要这个参数, bto_c2是导出的用户,bto_c2_nm是目前需要导数据的新的用户)
http://blog.itpub.net/28793776/viewspace-1472543/ (具体参数详解可以参考下这个,这里只说了下平时用的比较多的)
具体操作:
[oracle@hadoop1 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Wed Apr 12 10:32:13 2017
Copyright © 1982, 2009, Oracle. 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
SQL> create or replace directory dump_dir as ‘/opt/oracle/dump_dir’; ///opt/oracle/dump_dir ,oracle用户
select * from dba_directories; (查看指向是否创建成功,可以直接在plsql查看)
dmp文件存放地址 dump_dir只是一个指向*
expdp 、impdp不要在sqlplus下执行,在Oracle用户下linux服务器上就可以了
导入数据:
impdp bto_c2_nm/oss@orcl DIRECTORY=dump_dir DUMPFILE=nm_bto_c2.dmp logfile=nm_bto_c2.log tables=bto_c2.categorydtl,bto_c2.seriesdtl REMAP_SCHEMA = bto_c2:bto_c2_nm;
exp 与 expdp 的区别
在10g之前,传统的导出和导入分别使用EXP工具和IMP工具,从10g开始,不仅保留了原有的EXP和IMP工具,还提供了数据泵导出导入工具EXPDP和IMPDP.使用EXPDP和IMPDP时应该注意的事项:
1)EXP和IMP是客户端工具程序,它们既可以在可以客户端使用,也可以在服务端使用。
2)EXPDP和IMPDP是服务端的工具程序,他们只能在ORACLE服务端使用, 不能在客户端使用。
3)IMP 只适用于EXP 导出文件, 不适用于EXPDP 导出文件;IMPDP 只适用于EXPDP 导出文件, 而不适用于EXP 导出文件。
(其中数据泵取只能在服务器端运行,客户端只能用来连接服务器启动导入导出操作)
exp和expdp都可以导出数据文件但是个人觉得expdp更好用点,毕竟是新的嘛,遇到几次exp导出没任何问题,但是用imp导入就会出问题,也不清楚问题在哪,导出也是成功的,很郁闷,所以还是建议用expdp做吧,避免遇到一些问题