数据的导入导出时数据库经常处理的作业之一,Oracle 提供了IMP和IMPDP以及SQL*Loader等工具来完成数据的导入工作,其中IMP服务于早期的9i之前的版本,在10g及后续版本,Oracle 提供了数据泵高速导入工具,本文主要介绍IMPDP的使用方法,关于高速导出工具请参照:
数据泵EXPDP 导出工具的使用 见 http://www.linuxidc.com/Linux/2012-01/51796.htm。SQL*Loader请参照:
SQL*Loader使用方法 见 http://www.linuxidc.com/Linux/2012-01/51798.htm。 一、数据泵的体系结构 数据泵的体系结构在数据泵EXPDP 导出工具的使用已列出,再此不再赘述。 二、IMPDP支持的接口及导入模式 导入接口 使用命令行带参数的 使用命令行带参数文件 使用命令行交互 使用database console(GUI) 几种常用的导入模式 导入表 导入方案 导入表空间 导入数据库 传输表空间模式 三、演示如何导入 1.关于查看impdp的帮助,使用以下命令 [oracle@oradb ~]$ impdp -? 或[oracle@oradb ~]$ impdp -help 前者提供帮助信息并开启命令行交互模式 2. 导入表 --将表dept,emp导入到scott方案中 impdp scott/tiger directory=dump_scott dumpfile=tab.dmp tables=dept,emp --将表dept和emp从scott方案导入到system方案中,对于方案的转移,必须使用remap_shcema参数 impdp system/manage directory=dump_scott dumpfile=tab.dmp tables=scott.dept,scott.emp remap_schema=scott:system 3.导入方案 --将dump_scott目录下的schema.dmp导入到scott方案中 impdp scott/tiger directory=dump_scott dumpfile=schema.dmp schemas=scott --将scott方案中的所有对象转移到system方案中 impdp system/RedHat directory=dump_scott dumpfile=schema.dmp schemas=scott remap_schema=scott:system 4.导入表空间 impdp system/redhat directory=dump_scott dumpfile=tablespace.dmp tablespaces=user01 5.导入数据库 impdp system/redhat directory=dump_scott dumpfile=full.dmp full=y 6.将数据对象原样导回(演示从Windows客户端来实现,数据库基于Linux系统) 从Windows客户端来导出scott.emp表,导出后删除该表,再原样导回 C:/>expdp scott/tiger@list2 directory=dump_scott dumpfile=emp.dmp tables=emp C:/>sqlplus scott/tiger@list2 SQL*Plus: Release 10.2.0.1.0 - Production on 星期一9月20 20:50:35 2010 Copyright (c) 1982, 2005, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options SQL> drop table emp; Table dropped. SQL> commit; Commit complete. SQL> select count(1) from emp; select count(1) from emp * ERROR at line 1: ORA-00942: table or view does not exist SQL> host impdp scott/tiger@list2 directory=dump_scott dumpfile=emp.dmp SQL> select count(1) from emp; COUNT(1) ---------- 14 7.将导出的对象使用remap_schema参数转移到不同的方案 a.将dept从scott用户导入到system用户下 expdp scott/tiger directory=dump_scott dumpfile=dept.dmp tables=dept 方法一: impdp system/redhat tables=scott.dept directory=dump_scott dumpfile=dept.dmp remap_schema=scott:system 方法二: sql>grant imp_full_database to scott; impdp scott/tiger directory=dump_scott dumpfile=dept.dmp tables=dept remap_schema=scott:system table_exists_action=replace b.将scott方案下的所有对象导入到system方案下 expdp scott/tiger directory=dump_scott dumpfile=allobj.dmp schemas=scott impdp scott/tiger directory=dump_scott dumpfile=allobj.dmp remap_schema=scott:system table_exists_action=replace 8.使用remap_datafile参数转移到不同的数据文件(用于不同平台之间存在不同命名方式时) 下面的示例首先创建了一个参数文件,参数文件名为payroll.par directory=pump_scott full=y dumpfile=datafile.dmp remap_datafile="db$:[hrdata.payroll]tbs2.f":"/db/hrdata/payroll/tbs2.f" --指明重新映射数据文件 impdp scott/tiger PARFILE=payroll.par 9.使用remap_tablespace参数转移到不同的表空间 impdp scott/scott remap_tablespace=users:tbs1 directory=dpump_scott dumpfile=users.dmp 10.并行导入: expdp e/e directory=dump_e dumpfile=a_%u.dmp schemas=e parallel=3 impdp e/e directory=dump_e dumpfile=a_%u.dmp schemas=e parallel=3 table_exists_action=replace
数据泵 EXPDP 导出工具的使用SQL*Loader使用方法相关资讯 Oracle基础教程
- Oracle块编程返回结果集详解 (11/10/2013 10:45:58)
- Oracle基础教程之设置系统全局区 (08/22/2013 14:24:00)
- Oracle基础教程知识点总结 (06/18/2013 07:43:32)
| - Oracle基础教程之tkprof程序详解 (10/22/2013 11:49:50)
- Oracle基础教程之sqlplus汉字乱码 (07/18/2013 16:30:00)
- Oracle 管理之 Linux 网络基础 (02/16/2013 18:37:35)
|
本文评论 查看全部评论 (0)