ORACLE EXPDP/IMPDP数据导入导出(只支持服务端)
前言:
1.先在服务器上建立存放目录
mkdir -p /dbfile/oracledump
chown -R oracle:oinstall /dbfile/oracledump
2.在oracle中创建逻辑目录
create directory MY_DIR as '/dbfile/backup';
grant read, write on directory MY_DIR to public;
3.新建表空间及用户用于以下EXPDP/IMPDP:
create tablespace test datafile '/dbfile/oracle/app/oradata/system/test.dbf' size 2G;
create user test identified by "test.111" default tablespace test temporary tablespace temp;
grant connect,resource to test;
4.查看实例名
select instance_name from v$instance;
EXPDP导出/IMPDP导入
1.test全库导出
expdp system/password@system directory=MY_DIR dumpfile=test1022.dmp logfile=test1022.log schemas=test;
impdp system/password@system directory=MY_DIR dumpfile=test1022.dmp logfile=test1022.log schemas=test;
2.test表结构导出(不含数据)
expdp system/password@system directory=MY_DIR dumpfile=test1022.dmp logfile=test1022.log schemas=test content=metadata_only;
impdp system/password@system directory=MY_DIR dumpfile=test1022.dmp logfile=test1022.log schemas=test;
3.test单表导出
expdp system/password@system directory=MY_DIR dumpfile=table_name.dmp logfile=table_name.log tables=test.table_name
impdp system/password@system directory=MY_DIR dumpfile=table_name.dmp logfile=table_name.log
4.test中导出以a开头的表
expdp system/password@system directory=MY_DIR dumpfile=test.dmp logfile=test.log tables=TEST.A%
impdp system/password@system directory=MY_DIR dumpfile=test.dmp logfile=test.log
5.如test中表过大,仅导出前一万笔数据
expdp system/password@system directory=MY_DIR dumpfile=test.dmp logfile=test.log schemas=test query='"where rownum<=10000"'
impdp system/password@system directory=MY_DIR dumpfile=test.dmp logfile=test.log
6.通过dblink expdp远程数据库(需先在test用户下新建dblink)
expdp test/test.111@system directory=MY_DIR dumpfile=test.dmp network_link=linkname_xxx
table_exists_action参数说明
使用impdp完成数据库导入时,若表已经存在,有四种的处理方式:
1) skip:默认操作
2) replace:先drop表,然后创建表,最后插入数据
3) append:在原来数据的基础上增加数据
4) truncate:先truncate,然后再插入数据
终止expdp/impdp
直接Ctrl+C ,然后stop_job=immediate
如已退出expdp/impdp界面,则
select job_name,state from dba_datapump_jobs;
expdp system/password@rac attach=SYS_EXPORT_SCHEMA_01
stop_job=immediate
终止exp/imp
ps -ef|grep imp
kill -9 6745