expdp 和impdp

Data Pump Export (invoked with the expdp command) is a new utility as of Oracle Database 10g. Although its functionality and its paramters are similar to those of the original export utility(exp), they are commpletely separate utilities and their files are not compatible.

数据埠导出(expdp)是oracle 10g新的功能。虽然功能和参数都类似之前的exp,但他们完全分离的功能而且他们的文件不兼容。

expdp:首先要建立个directory,然后授予权限给指定用户

create or replace directory expdp_test_dir as ‘/home/oracle/test’

grant read,write on directory expdp_test_dir to scott

host expdp scott/tiger directory=expdp_test_dir dumpfile=tab.dmp tables=dept,emp

image

没有dumpfile也是可以执行成功的,默认的导出结果是:expdat.dmp;如下图

host expdp scott/tiger directory=expdp_test_dir tables=dept,emp

image

上面只是试着使用expdp的语法

下面是按照官方文档的Data Pump Export Modes

1.Full Export Mode

host expdp system/oracle@orcl directory=expdp_test_dir dumpfile=expdpdull.dmp full=y

image

dumpfile原本是想写expdpfull.dmp的,手指不听使唤了。截图只是截了最后一小段。

This mode requires that you have DATAPUMP_EXP_FULL_DATABASE role。这个不写肯定也知道,权限问题。可以把system改为sys, host expdp ”sys/oracle@orcl as sysdba” directory=expdp_test_dir dumpfile expdpfull.dmp full=y

2.Schema Mode

host expdp scott/tiger@orcl  directory=expdp_test_dir dumpfile=scott.dmp schemas=scott

是schemas,不是exp中owner了

3.Table Mode

host expdp scott/tiger@orcl directory=expdp_test_dir dumpfile=deptemp.dmp tables=dept,emp

4.Tablespace Mode

host expdp system/oracle@orcl directory=expdp_test_dir dumpfile=tablespace.dmp logfile=tablespace.log tablespaces=system

image

image

这个Mode我加了logfile哦!log文件也是在directory路径下哦

5.Transportable Tablespace Mode

In transportable tablespace mode, only the metadata for the tables (and their dependent objects) within a specified set of tablespaces is exported. The tablespace data files are copied in a separate operation. Then, a transportable tablespace import is performed to import the dump file containing the metadata and to specify the data files to use.

大意就是:在transportable tablespace 模式下,只有表的元数据和他们依靠的对象(元数据就是解释数据的数据,个人理解,之前其他地方看到过metadata,其书上也是这么解释的,不是oracle方面的书哦,不要轻信啊)被导出。表空间数据文件被复制是分离的操作。transportable tablespace 导入时执行导入dump 文件(元数据和特定的数据文件)。

这个没例子举了,SYSTEM表空间不被包括在内的,USERS和UNDOTBS1又都是只读的。

host expdp system/oracle@orcl directory=expdp_test_dir dumpfile=transport.dmp logfile=transport.log transport_tablespaces=”tablespace name”

impdp和expdp很类似,上面的例子把expdp替换成impdp应该就可以导入了(没做测试哦,改天再接上吧)。impdp导入的文件只能是expdp导出的文件,不能是exp导出的文件。

原文地址:https://www.cnblogs.com/cnmarkao/p/3674379.html