知识要点
- expdp impdp 是10g产生的工具,相比exp imp性能有所改良
- expdp impdp 的使用方法。可以看到两者语法大致相同。
expdp使用方法
- sqlplus:create directory exp as '/u01'
- 授予要导入导出的用户读写权限,普通用户要做这一步。不然会报错
- grant read,write on directory exp to scott;
- ORA-39002: invalid operation
- ORA-39070: Unable to open the log file.
- ORA-39087: directory name /U01 is invalid
- expdp system/oracle directory=dump dumpfile=mark_%U.dmp logfile=user.log schemas=mark parallel=2 flashback_scn=2439926//这里的SCN就是之前查询得到的当前SCN
- --导出表 -help 帮助 expdp scott/tiger DIRECTORY=exp DUMPFILE=scott01.dmp tables=emp,dept
- --导出schema expdp scott/tiger DIRECTORY=exp DUMPFILE=scott02.dmp schemas=scott;
- --导出全库 expdp \'sys/123 as sysdba\' full=y DIRECTORY=exp DUMPFILE=scott03.dmp
impdp使用方法
- table_exists_action的选项APPEND,REPLACE,[SKIP] and TRUNCATE,skip是默认
REPLACE和TRUNCATE的区别是前者不释放空间,后者释放空间
- 导入表
- impdp scott/tiger DIRECTORY=exp DUMPFILE=scott01.dmp tables=emp,dept table_exists_action=replace
- --从一个schema scott 给另一个schema ogg impdp scott/tiger DIRECTORY=exp DUMPFILE=scott02.dmp remap_schema=scott:ogg
- 1.创建parfile文件
- [oracle@host u01]$ vi /u01/dp.txt
- userid=scott/tiger
- DIRECTORY=exp
- DUMPFILE=scott01.dmp
- tables=emp,dept
- table_exists_action=replace
-
- 2.impdp parfile=/u01/dp.txt
- impdp scott/tiger DIRECTORY=exp DUMPFILE=scott02.dmp schemas=scott