数据泵使用:expdb和impdb

expdb导出数据库用户的数据,可以限制含(include), 或排除(exclude)某些表名,或按sql查询表名, 使用时需要用配置文件,如下:

--假设oracle用户为wisg,需排除一些_HIS结尾的表.  %U为并行度的多个文件编号

[oracle@redhat-inux1 ~]$ more expdb_cfg_wisg.par
directory=wisgdump
dumpfile=wisg_expdb20200727_%U.dmp
SCHEMAS=wisg
logfile=wisg_expdb20200727.log
parallel=5
exclude=table:"in(select table_name from user_tables where table_name like '%_HIS' )"

[oracle@edhat-inux1 ~]$ expdp wisg/password@wisgdb parfile=expdb_cfg_wisg.par

其中directory要提前用sql创建,用于存放导入或导出的dump文件,例如这个目录/dmp/expdp

SQL> create or replace directory wisgdump as '/dmp/expdp';

SQL> grant read,write on directory wisgdump to wisg;

 

导入示例:  导入到wisg2用户( 该用户对应的表空间为tbs2)

[oracle@redhat-inux2 ~]$ impdp wisg2/wisg2@orcl directory=wisgdump dumpfile=wisg_expdb20200727_%U.dmp logfile=wisg_expdb20200727_impdp.log parallel=5 REMAP_SCHEMA=wisg:wisg2 remap_tablespace=tbs1:tbs2

如果导入时的用户名相同,表空间名也相同,则简单一些

[oracle@redhat-inux2 ~]$ impdp wisg/wisg@orcl directory=wisgdump dumpfile=wisg_expdb20200727_%U.dmp logfile=wisg_expdb20200727_impdp.log parallel=5 schemas=wisg

你可能感兴趣的:(Oracle)