Heim  >  Artikel  >  Datenbank  >  Oracle expdp/impdp使用示例

Oracle expdp/impdp使用示例

WBOY
WBOYOriginal
2016-06-07 15:19:141243Durchsuche

使用EXPDP和IMPDP时应该注意的事项: EXP和IMP是客户端工具程序,它们既可以在客户端使用,也可以在服务端使用。 EXPDP和IMPDP是服务端的工具程序,他们只能在ORACLE服务端使用,不能在客户端使用。 IMP只适用于EXP导出的文件,不适用于EXPDP导出文件;IMPDP

使用EXPDP和IMPDP时应该注意的事项:

EXP和IMP是客户端工具程序,它们既可以在客户端使用,也可以在服务端使用。

EXPDP和IMPDP是服务端的工具程序,他们只能在ORACLE服务端使用,不能在客户端使用。

IMP只适用于EXP导出的文件,不适用于EXPDP导出文件;IMPDP只适用于EXPDP导出的文件,而不适用于EXP导出文件。

expdp或impdp命令时,可暂不指出用户名/密码@实例名 as 身份,然后根据提示再输入,如:

expdp schemas=scott dumpfile=expdp.dmp DIRECTORY=dpdata1;

一、创建逻辑目录,该命令不会在操作系统创建真正的目录,最好以system等管理员创建。

create or replace directory dpdata1 as 'd:\test\dump';

二、查看管理理员目录(同时查看操作系统是否存在,因为Oracle并不关心该目录是否存在,如果不存在,则出错)

select * from dba_directories;

三、给scott用户赋予在指定目录的操作权限,最好以system等管理员赋予。

grant read,write on directory dpdata1 to scott;

四、导出数据

1)按用户导

expdp system/managerdirectory=dumpdir dumpfile=expdp.dmps chemas=scott;

2)并行进程parallel

expdp system/manager directory=dumpdir dumpfile=para_export%u.dmp parallel=2 job_name=scott3

3)按表名导

expdp system/manager directory=dumpdir dumpfile=expdp.dmp DIRECTORY=dpdata1;

4)按查询条件导

expdp system/manager directory=dumpdir dumpfile=expdp.dmp Tables=emp query='WHERE deptno=20';

5)按表空间导

expdp system/manager directory=dumpdirdumpfile=tablespace.dmp TABLESPACES=temp,example;

6)导整个数据库

expdp system/manager directory=dumpdirdumpfile=full.dmp FULL=y;

7)计算导出作业所需要的空间,默认采用blocks method

expdp system/system directory=dumpdir full=y estimate_only=y estimate=[statistics|blocks]

8)只导出表结构

        expdp system/manager directory=dumpdir dumpfile=expdp.dmp schemas=hruser content=metadata_only

五、导入数据

1)导到指定用户下

impdp system/manager directory=dumpdir dumpfile=expdp.dmp SCHEMAS=scott;

2)改变表的owner

impdp system/manager directory=dumpdir dumpfile=expdp.dmp TABLES=scott.dept REMAP_SCHEMA=scott:viin REMAP_TABLESPACE=users:pay

3)导入表空间

impdp system/manager directory=dumpdir dumpfile=expdp.dmp TABLESPACES=example;

4)导入数据库

impdb system/manager directory=dumpdir dumpfile=expdp.dmp FULL=y;

5)追加数据

impdp system/manager directory=dumpdir dumpfile=expdp.dmp SCHEMAS=system TABLE_EXISTS_ACTION=append

关于TABLE_EXISTS_ACTION的使用方法,请参照http://blog.csdn.net/chunhua_love/article/details/12001533

六、传输表空间

       1)验证表空间是否自包含


       execute sys.dbms_tts.transport_set_check('USERS',true)


       2)将表空间置于只读状态


       alter tablespace users read only


       3)导出迁移表空间的目录元数据,并且将导出文件和迁移表空间对应的数据文件拷贝到目标数据库的指定目录下


       expdp system/manager directory=dumpdir dumpfile=expdp.dmp transport_tablespaces=users


       4)在目标数据库导入迁移表空间


       impdp system/manager directory=dumpdir dumpfile=expdp.dmp transport_datafiles=users01.dbf

备注:

1、客户端字符集NLS_LANG=language_territory.charset应该与数据库字符集一样,至少客户端和目标数据库字符集应该是源数据库字符集的严格超集,但是这种情况会存在字符集转换。

2、从11g版本迁移到10g版本,需要在expdp时指定参数version=10.2。

3、导出导入时可以指定job_name、logfile参数,以便查询视图dba_datapump_jobs跟踪导出导入,并且在结束后,查询日志是否有失败和警告。

        4、改变一个对象的owner 以及对象所在的tablespace oracle 提供了以下两种方式:

        exp/imp  fromuser touser 

        expdp/impdp  remap_schema remap_tablespace

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Vorheriger Artikel:Sqlserver2012 alwayson部署攻略Nächster Artikel:【MySQL案例】HA: GTID