Home > Database > Mysql Tutorial > Oracle 10g expdp/impdp在项目中实践总结

Oracle 10g expdp/impdp在项目中实践总结

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 17:14:11
Original
1167 people have browsed it

自 Oracle 10g 版本开始,数据泵 (data dump) 作为一种新的数据移动技术提供出来。使用这个技术工具分别为 expdp 和 impdp 。我们

自 Oracle 10g 版本开始,数据泵 (data dump) 作为一种新的数据移动技术提供出来。使用这个技术工具分别为 expdp 和 impdp 。我们在实际项目中经常使用到它们,如从生产库向测试库迁移数据。

我介绍一下这两个工具的用途、使用方法、以及它们与 9i 的 imp/exp 的区别。

expdp 和 impdp 的主要用途有三点,分别是:

1 、实现数据库的逻辑备份和恢复;

2 、在相同或不同的数据库的不同用户之间移动数据库对象如表定义和数据、函数、存储过程;

3 、可以和 rman 联合使用,实现表空间级别的数据快速迁移。

(注,这个用途,我专门在一文中注明了其实现过程: exp/expdp 传输表空间和 rman convert 实现大数据量快速迁移

expdp 和 impdp 的使用中有很多参数选项,不同的选项实现不同的功能。这里先重点介绍一下 expdp 的主要功能点。

1 、导出某一个用户,加 schemas

2 、导出一个用户下导出部分表,加 tables

3 、导出一个用户下不包括某些表,加 exclude

4 、导出所有表的符合某个条件(如表的前 10000 行)的记录,加 query

5 、导出某个时间点或 SCN 的数据镜像,加 flashback_time 或 flashback_scn

这个功能用于 streams 、 ogg 等数据实时同步工具的实例化操作。

6 、导出数据库的元数据或全部数据,,加 CONTENT={ALL | DATA_ONLY | METADATA_ONLY}

7 、导出数据库某个表空间的元数据,用于表空间快速迁移,加 transport_tablespace=y   tablespaces=tbs_name

8 、限制每个导出文件的大小,加 filesize

还可以限制每个导出文件的大小,加并行度,统计导出对象等其他功能。这些功能我日常用的不多,可以参数 expdp –help 。

expdp 工具的使用示例如下:

expdp qlzq/qlzqp SCHEMAS=ebmall directory=test dumpfile=ebmall.dmp logfile=ebmall.log

这是实现将用户 ebmall 下所有对象导出到目录 test 下的 ebmall.dmp 文件中的操作,记录的日志文件为 ebmall.log 。

expdp qlzq/qlzqp directory=test dumpfile=qlzq.dmp logfile=qlzq.log EXCLUDE=TABLE:\"IN \(\'CMS_DOC_BODY\',\' MAIL_QUEUE_FILE\',\'S

ERVICE_LOG\',\'MSG_MAIL_HISTORY\',\'MAIL_QUEUE_FILE\'\)\"

这是实现导出一个用户下除掉部分表之外的所有对象的操作。在 expdp 使用过程中,这三个参数 directory 、 dumpfile 、 logfile 是必须加上。

impdp 工具的功能有很多,主要使用到的功能是 rmap_schema ,参数为 REMAP_SCHEMA=source_schema:target_schema

其他的功能可参考 impdp -help

impdp system/oracl directory=qlzq dumpfile=qlzq.dmp logfile=qlzq.log

在目标库上,导入前没有 qlzq 用户,使用 impdp 导入时可以自动创建。新建用户的密码都会和源库一样。导入前需要将表空间建立好,大小合适。

如果源库的 dmp 文件是使用 system 用户导出的另一个用户,则需要加 schemas 选项,指定导入用户。

如导出该 dmp 文件的用户是 qlzq, 那么导入时我们则需要执行 schemals 参数值

使用方法如下:

impdp system/oracl directory=qlzq schemas=ebmall dumpfile=ebmall.dmp logfile=ebmall.log

10g 的 expdp/impdp 和 exp/imp 的区别,我认为最主要的部分是前者是只能运行在数据库服务器端,后者可以在客户端或服务器端同时运行。

这个区别就涉及到跨平台的数据导入导出的问题。

更多Oracle相关信息见Oracle 专题页面 ?tid=12

linux

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template