EXPDP,IMPDP远程导出,导入数据库到本地
1.本地建立导出用户hr_exp并完全删除机hr的用户
C:\Users\Administrator>sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on 星期一 10月 27 15:11:01 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> create user hr_exp identified by hr_exp;
用户已创建。
SQL> grant connect,resource,create database link to hr_exp;
授权成功。
SQL> drop user hr cascade;
用户已删除。
2.在操作系统上创建目录
SQL> conn / as sysdba
已连接。
SQL> create or replace directory DIR_EXP as 'd:\direxp';
目录已创建。
SQL> grant read,write on directory DIR_EXP to hr_exp;
授权成功。
3.解锁远程用户的hr的帐户并修改其密码为hr
C:\Users\Administrator>sqlplus system/root@192.168.11.2:1521/orcl
SQL*Plus: Release 10.2.0.1.0 - Production on 星期一 10月 27 15:16:54 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> alter user hr account unlock;
用户已更改。
SQL> alter user hr identified by hr;
用户已更改。
SQL>
4.创建链接
SQL> conn hr_exp/hr_exp
已连接。
SQL> create database link to_exp_hr
2 connect to hr identified by hr
3 using '(DESCRIPTION =
4 (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.11.2)(PORT = 1521))
5 (CONNECT_DATA =
6 (SERVER = DEDICATED)
7 (SID = orcl)
8 )
9 )';
数据库链接已创建。
另外一种数据连接创建方式
SQL> create database link to_exp_hr connect to hr identified by hr using '192.168.11.2:1521/orcl';
SQL> Select 1 from dual@to_exp_hr;
1
----------
1
SQL>
5.导出hr的数据
C:\Users\Administrator>expdp hr_exp/hr_exp@192.168.11.1:1521/orcl directory=DIR_EXP dumpfile=hr_20141027.dmp logfile=hr_20141027.log network_link=to_exp_hr
Export: Release 10.2.0.1.0 - Production on 星期一, 27 10月, 2014 15:21:49
Copyright (c) 2003, 2005, Oracle. All rights reserved.
连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
启动 "HR_EXP"."SYS_EXPORT_SCHEMA_01": hr_exp/********@192.168.11.1:1521/orcl di
rectory=DIR_EXP dumpfile=hr_20141027.dmp logfile=hr_20141027.log network_link=to
_exp_hr
正在使用 BLOCKS 方法进行估计...
处理对象类型 SCHEMA_EXPORT/TABLE/TABLE_DATA
使用 BLOCKS 方法的总估计: 448 KB
处理对象类型 SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
处理对象类型 SCHEMA_EXPORT/SEQUENCE/SEQUENCE
处理对象类型 SCHEMA_EXPORT/TABLE/TABLE
处理对象类型 SCHEMA_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT
处理对象类型 SCHEMA_EXPORT/TABLE/INDEX/INDEX
处理对象类型 SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
处理对象类型 SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
处理对象类型 SCHEMA_EXPORT/TABLE/COMMENT
处理对象类型 SCHEMA_EXPORT/PROCEDURE/PROCEDURE
处理对象类型 SCHEMA_EXPORT/PROCEDURE/ALTER_PROCEDURE
处理对象类型 SCHEMA_EXPORT/VIEW/VIEW
处理对象类型 SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
处理对象类型 SCHEMA_EXPORT/TABLE/TRIGGER
处理对象类型 SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . 导出了 "HR"."COUNTRIES" 5.992 KB 25 行
. . 导出了 "HR"."DEPARTMENTS" 6.632 KB 27 行
. . 导出了 "HR"."EMPLOYEES" 15.76 KB 107 行
. . 导出了 "HR"."JOBS" 6.609 KB 19 行
. . 导出了 "HR"."JOB_HISTORY" 6.585 KB 10 行
. . 导出了 "HR"."LOCATIONS" 7.710 KB 23 行
. . 导出了 "HR"."REGIONS" 5.289 KB 4 行
已成功加载/卸载了主表 "HR_EXP"."SYS_EXPORT_SCHEMA_01"
******************************************************************************
HR_EXP.SYS_EXPORT_SCHEMA_01 的转储文件集为:
D:\DIREXP\HR_20141027.DMP
作业 "HR_EXP"."SYS_EXPORT_SCHEMA_01" 已于 15:22: