您好,欢迎访问一九零五行业门户网

数据泵expdp,impdp使用结

expdp,impdp远程导出,导入数据库到本地 1.本地建立导出用户hr_exp并完全删除机hr的用户 c:\users\administratorsqlplus / as sysdba sql*plus: release 10.2.0.1.0 - production on 星期一 10月 27 15:11:01 2014 copyright (c) 1982, 2005, oracle. all ri
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:20 成功完成
c:\users\administrator>
6.授权:expdp,impdp权限授予
sql> grant imp_full_database,exp_full_database to hr_exp;
授权成功。
sql>
7.本机导入
c:\users\administrator>impdp hr_exp/hr_exp directory=dir_exp dumpfile=hr_201410
7.dmp remap_schema=hr:hr_exp exclude=statistics
import: release 10.2.0.1.0 - production on 星期一, 27 10月, 2014 16:54:42
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_import_full_02
启动 hr_exp.sys_import_full_02: hr_exp/******** directory=dir_exp dumpfile
hr_20141027.dmp remap_schema=hr:hr_exp exclude=statistics
处理对象类型 schema_export/pre_schema/procact_schema
处理对象类型 schema_export/sequence/sequence
处理对象类型 schema_export/table/table
处理对象类型 schema_export/table/table_data
. . 导入了 hr_exp.countries 5.992 kb 25 行
. . 导入了 hr_exp.departments 6.632 kb 27 行
. . 导入了 hr_exp.employees 15.76 kb 107 行
. . 导入了 hr_exp.jobs 6.609 kb 19 行
. . 导入了 hr_exp.job_history 6.585 kb 10 行
. . 导入了 hr_exp.locations 7.710 kb 23 行
. . 导入了 hr_exp.regions 5.289 kb 4 行
处理对象类型 schema_export/table/grant/owner_grant/object_grant
处理对象类型 schema_export/table/index/index
处理对象类型 schema_export/table/constraint/constraint
处理对象类型 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
作业 hr_exp.sys_import_full_02 已于 16:54:51 成功完成
遇到的问题:未授权
c:\users\administrator>impdp hr_exp/hr_exp directory=dir_exp dumpfile=hr_20141027.dmp remap_schema=hr:hr_exp exclude=statistics
import: release 10.2.0.1.0 - production on 星期一, 27 10月, 2014 16:51:35
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
ora-31631: 需要权限
ora-39122: 未授权的用户不能执行 remap_schema 重新映射。
解决方法
c:\users\administrator>sqlplus / as sysdba
sql*plus: release 10.2.0.1.0 - production on 星期一 10月 27 16:52:40 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> grant imp_full_database,exp_full_database to hr_exp;
授权成功。
sql>
其他备注:
hr_exp 本地用户,用来连接远端数据库服务器
dir_exp 本地用户下hr_exp的 directory 用户本地指定expdp写入目录,这里是d盘direxp文件夹
to_exp_hr 本地hr_exp用户下的 db link ,用来连接远端数据库服务器
本机exp数据导出方式:
--这里以scott为例
c:\users\administrator>sqlplus / as sysdba
sql*plus: release 10.2.0.1.0 - production on 星期一 10月 27 17:11:23 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> grant connect,resource,create database link to scott;
授权成功。
sql> grant imp_full_database,exp_full_database to hr_exp;
授权成功。
sql> grant read,write on directory dir_exp to scott;
授权成功。
--全部导出(expdp scott/scott@192.168.11.1:1521/orcl directory=dir_exp dumpfile=scott_full.dmp logfile=scott_full.log )
c:\users\administrator>expdp scott/scott@192.168.11.1:1521/orcl directory=dir_exp dumpfile=scott_full.dmp logfile=scott_full.log
export: release 10.2.0.1.0 - production on 星期一, 27 10月, 2014 17:21:29
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
启动 scott.sys_export_schema_01: scott/********@192.168.11.1:1521/orcl dire
ctory=dir_exp dumpfile=scott_full.dmp logfile=scott_full.log
正在使用 blocks 方法进行估计...
处理对象类型 schema_export/table/table_data
使用 blocks 方法的总估计: 192 kb
处理对象类型 schema_export/pre_schema/procact_schema
处理对象类型 schema_export/table/table
处理对象类型 schema_export/table/index/index
处理对象类型 schema_export/table/constraint/constraint
处理对象类型 schema_export/table/index/statistics/index_statistics
处理对象类型 schema_export/table/comment
处理对象类型 schema_export/table/constraint/ref_constraint
处理对象类型 schema_export/table/statistics/table_statistics
. . 导出了 scott.dept 5.656 kb 4 行
. . 导出了 scott.emp 7.820 kb 14 行
. . 导出了 scott.salgrade 5.585 kb 5 行
. . 导出了 scott.bonus 0 kb 0 行
已成功加载/卸载了主表 scott.sys_export_schema_01
******************************************************************************
scott.sys_export_schema_01 的转储文件集为:
d:\direxp\scott_full.dmp
作业 scott.sys_export_schema_01 已于 17:21:49 成功完成
按表导出
expdp scott/scott@192.168.11.1:1521/orcl directory=dir_exp dumpfile=scott_emp.dmp logfile=scott_emp.log tables=scott.emp
c:\users\administrator>expdp scott/scott@192.168.11.1:1521/orcl directory=dir_exp dumpfile=scott_emp.dmp logfile=scott_emp.log tables=scott.emp
export: release 10.2.0.1.0 - production on 星期一, 27 10月, 2014 17:23:14
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
启动 scott.sys_export_table_01: scott/********@192.168.11.1:1521/orcl direc
tory=dir_exp dumpfile=scott_emp.dmp logfile=scott_emp.log tables=scott.emp
正在使用 blocks 方法进行估计...
处理对象类型 table_export/table/table_data
使用 blocks 方法的总估计: 64 kb
处理对象类型 table_export/table/table
处理对象类型 table_export/table/index/index
处理对象类型 table_export/table/constraint/constraint
处理对象类型 table_export/table/index/statistics/index_statistics
处理对象类型 table_export/table/constraint/ref_constraint
处理对象类型 table_export/table/statistics/table_statistics
. . 导出了 scott.emp 7.820 kb 14 行
已成功加载/卸载了主表 scott.sys_export_table_01
******************************************************************************
scott.sys_export_table_01 的转储文件集为:
d:\direxp\scott_emp.dmp
作业 scott.sys_export_table_01 已于 17:23:25 成功完成
按表空间导出
expdp scott/scott@127.0.0.1:1521/orcl directory=dir_exp dumpfile=scott_tablespace.dmp tablespaces=users
c:\users\administrator> expdp scott/scott@127.0.0.1:1521/orcl directory=dir_exp dumpfile=scott_tablespace.dmp tablespaces=users
export: release 10.2.0.1.0 - production on 星期一, 27 10月, 2014 20:51:25
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
启动 scott.sys_export_tablespace_01: scott/********@127.0.0.1:1521/orcl dir
ectory=dir_exp dumpfile=scott_tablespace.dmp tablespaces=users
正在使用 blocks 方法进行估计...
处理对象类型 table_export/table/table_data
使用 blocks 方法的总估计: 192 kb
处理对象类型 table_export/table/table
处理对象类型 table_export/table/index/index
处理对象类型 table_export/table/constraint/constraint
处理对象类型 table_export/table/index/statistics/index_statistics
处理对象类型 table_export/table/comment
处理对象类型 table_export/table/constraint/ref_constraint
处理对象类型 table_export/table/statistics/table_statistics
. . 导出了 scott.dept 5.656 kb 4 行
. . 导出了 scott.emp 7.820 kb 14 行
. . 导出了 scott.salgrade 5.585 kb 5 行
. . 导出了 scott.bonus 0 kb 0 行
已成功加载/卸载了主表 scott.sys_export_tablespace_01
******************************************************************************
scott.sys_export_tablespace_01 的转储文件集为:
d:\direxp\scott_tablespace.dmp
作业 scott.sys_export_tablespace_01 已于 20:51:39 成功完成
导出方案(expdp scott/scott@192.168.11.1:1521/orcl directory=dir_exp dumpfile=schema.dmp schemas=scott)
c:\users\administrator>expdp scott/scott@192.168.11.1:1521/orcl directory=dir_ex
p dumpfile=schema.dmp schemas=scott
export: release 10.2.0.1.0 - production on 星期一, 27 10月, 2014 17:31:23
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
启动 scott.sys_export_schema_01: scott/********@192.168.11.1:1521/orcl dire
ctory=dir_exp dumpfile=schema.dmp schemas=scott
正在使用 blocks 方法进行估计...
处理对象类型 schema_export/table/table_data
使用 blocks 方法的总估计: 192 kb
处理对象类型 schema_export/pre_schema/procact_schema
处理对象类型 schema_export/table/table
处理对象类型 schema_export/table/index/index
处理对象类型 schema_export/table/constraint/constraint
处理对象类型 schema_export/table/index/statistics/index_statistics
处理对象类型 schema_export/table/comment
处理对象类型 schema_export/table/constraint/ref_constraint
处理对象类型 schema_export/table/statistics/table_statistics
. . 导出了 scott.dept 5.656 kb 4 行
. . 导出了 scott.emp 7.820 kb 14 行
. . 导出了 scott.salgrade 5.585 kb 5 行
. . 导出了 scott.bonus 0 kb 0 行
已成功加载/卸载了主表 scott.sys_export_schema_01
******************************************************************************
scott.sys_export_schema_01 的转储文件集为:
d:\direxp\schema.dmp
作业 scott.sys_export_schema_01 已于 17:31:37 成功完成
按查询条件导出(expdp scott/scott@192.168.11.1:1521/orcl tables=scott.emp dumpfile =scott_where.dmp logfile=scott_where.log directory=dir_exp query='where rownum)
c:\users\administrator>expdp scott/scott@192.168.11.1:1521/orcl tables=scott.em
p dumpfile =scott_where.dmp logfile=scott_where.log directory=dir_exp query='w
here rownum
export: release 10.2.0.1.0 - production on 星期一, 27 10月, 2014 17:34:28
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
启动 scott.sys_export_table_01: scott/********@192.168.11.1:1521/orcl table
s=scott.emp dumpfile =scott_where.dmp logfile=scott_where.log directory=dir_exp
query='where rownum正在使用 blocks 方法进行估计...
处理对象类型 table_export/table/table_data
使用 blocks 方法的总估计: 64 kb
处理对象类型 table_export/table/table
处理对象类型 table_export/table/index/index
处理对象类型 table_export/table/constraint/constraint
处理对象类型 table_export/table/index/statistics/index_statistics
处理对象类型 table_export/table/constraint/ref_constraint
处理对象类型 table_export/table/statistics/table_statistics
. . 导出了 scott.emp 7.664 kb 10 行
已成功加载/卸载了主表 scott.sys_export_table_01
******************************************************************************
scott.sys_export_table_01 的转储文件集为:
d:\direxp\scott_where.dmp
作业 scott.sys_export_table_01 已于 17:34:39 成功完成
c:\users\administrator>
导出的相关命令使用:
1)ctrl+c组合键:在执行过程中,可以按ctrl+c组合键退出当前交互模式,退出之后,导出操作不会停止
2)export> status --查看当前job的状态及相关信息
3)export> stop_job --暂停job(暂停job后会退出expor模式)
4)重新进入export模式下:c:\documents and settings\administrator>expdp lttfm/lttfm attach=lttfm.my_job1 --语句后面不带分号
5)export> start_job --打开暂停的job(并未开始重新执行)
6)export> continue_client --通过此命令重新启动 lttfm.my_job:
7)export> kill_job --取消当前的job并释放相关客户会话(将job删除同时删除dmp文件)
8)export> exit_client --通过此命令退出export模式(通过4)可再进入export模式下)
注:导出完成后job自动卸
使用exclude,include导出数据
1、include导出用户中指定类型的指定对象
--仅导出scott用户下以e开头的所有表,包含与表相关的索引,备注等。不包含过程等其它对象类型:
expdp scott/scott@192.168.11.1:1521/orcl dumpfile=scott_e.dmp logfile=scott_e.log directory=dir_exp include=table:\like \'e%\'\
c:\users\administrator>expdp scott/scott@192.168.11.1:1521/orcl dumpfile=scott_e
.dmp logfile=scott_e.log directory=dir_exp include=table:\like \'e%\'\
export: release 10.2.0.1.0 - production on 星期一, 27 10月, 2014 17:39:55
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
启动 scott.sys_export_schema_01: scott/********@192.168.11.1:1521/orcl dump
file=scott_e.dmp logfile=scott_e.log directory=dir_exp include=table:like \'e%\
'
正在使用 blocks 方法进行估计...
处理对象类型 schema_export/table/table_data
使用 blocks 方法的总估计: 64 kb
处理对象类型 schema_export/table/table
处理对象类型 schema_export/table/index/index
处理对象类型 schema_export/table/constraint/constraint
处理对象类型 schema_export/table/index/statistics/index_statistics
处理对象类型 schema_export/table/constraint/ref_constraint
处理对象类型 schema_export/table/statistics/table_statistics
. . 导出了 scott.emp 7.820 kb 14 行
已成功加载/卸载了主表 scott.sys_export_schema_01
******************************************************************************
scott.sys_export_schema_01 的转储文件集为:
d:\direxp\scott_e.dmp
作业 scott.sys_export_schema_01 已于 17:40:09 成功完成
--导出scott用户下排除e$开头的所有表:
expdp scott/scott@192.168.11.1:1521/orcl schemas=scott dumpfile=scott_not_e.dmp logfile=scott_not_e.log directory=dir_exp job_name=my_job include=table:\not like \'e$%\'\
c:\users\administrator>expdp scott/scott@192.168.11.1:1521/orcl schemas=scott du
mpfile=scott_not_e.dmp logfile=scott_not_e.log directory=dir_exp job_name=my_job
include=table:\not like \'e$%\'\
export: release 10.2.0.1.0 - production on 星期一, 27 10月, 2014 17:42:42
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
启动 scott.my_job: scott/********@192.168.11.1:1521/orcl schemas=scott dump
file=scott_not_e.dmp logfile=scott_not_e.log directory=dir_exp job_name=my_job i
nclude=table:not like \'e$%\'
正在使用 blocks 方法进行估计...
处理对象类型 schema_export/table/table_data
使用 blocks 方法的总估计: 192 kb
处理对象类型 schema_export/table/table
处理对象类型 schema_export/table/index/index
处理对象类型 schema_export/table/constraint/constraint
处理对象类型 schema_export/table/index/statistics/index_statistics
处理对象类型 schema_export/table/comment
处理对象类型 schema_export/table/constraint/ref_constraint
处理对象类型 schema_export/table/statistics/table_statistics
. . 导出了 scott.dept 5.656 kb 4 行
. . 导出了 scott.emp 7.820 kb 14 行
. . 导出了 scott.salgrade 5.585 kb 5 行
. . 导出了 scott.bonus 0 kb 0 行
已成功加载/卸载了主表 scott.my_job
******************************************************************************
scott.my_job 的转储文件集为:
d:\direxp\scott_not_e.dmp
作业 scott.my_job 已于 17:42:56 成功完成
--仅导出scott用户下的所有存储过程:
expdp scott/scott@192.168.11.1:1521/orcl schemas=scott dumpfile=scott_procedure.dmp logfile=scott_procedure.log directory=dir_exp job_name=my_job include=procedur
2、exclude导出用户中指定类型的指定对象
--导出lttfm用户下除table类型以外的所有对象,如果表不导出那么与表相关的索引,约束等与表有关联的对象类型也不会被导出:
expdp scott/scott@192.168.11.1:1521/orcl schemas=scott dumpfile=scott_not_table.dmp logfile=scott_not_table.log directory=dir_exp job_name=my_job exclude=table;
c:\users\administrator>expdp scott/scott@192.168.11.1:1521/orcl schemas=scott du
mpfile=scott_not_table.dmp logfile=scott_not_table.log directory=dir_exp job_nam
e=my_job exclude=table
export: release 10.2.0.1.0 - production on 星期一, 27 10月, 2014 17:56:08
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
启动 scott.my_job: scott/********@192.168.11.1:1521/orcl schemas=scott dump
file=scott_not_table.dmp logfile=scott_not_table.log directory=dir_exp job_name=
my_job exclude=table
正在使用 blocks 方法进行估计...
处理对象类型 schema_export/table/table_data
使用 blocks 方法的总估计: 0 kb
处理对象类型 schema_export/pre_schema/procact_schema
已成功加载/卸载了主表 scott.my_job
******************************************************************************
scott.my_job 的转储文件集为:
d:\direxp\scott_not_table.dmp
作业 scott.my_job 已于 17:56:11 成功完成
--导出scott用户下排除e$开头的所有表:
expdp scott/scott@192.168.11.1:1521/orcl dumpfile=scott_not_e_begin.dmp logfile=scott_not_e_begin.log directory=dir_exp job_name=my_job exclude=table:\like\'e$%\'\
c:\users\administrator>expdp scott/scott@192.168.11.1:1521/orcl dumpfile=scott_n
ot_e_begin.dmp logfile=scott_not_e_begin.log directory=dir_exp job_name=my_job e
xclude=table:\like\'e$%\'\
export: release 10.2.0.1.0 - production on 星期一, 27 10月, 2014 17:58:16
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
启动 scott.my_job: scott/********@192.168.11.1:1521/orcl dumpfile=scott_not
_e_begin.dmp logfile=scott_not_e_begin.log directory=dir_exp job_name=my_job exc
lude=table:like\'e$%\'
正在使用 blocks 方法进行估计...
处理对象类型 schema_export/table/table_data
使用 blocks 方法的总估计: 192 kb
处理对象类型 schema_export/pre_schema/procact_schema
处理对象类型 schema_export/table/table
处理对象类型 schema_export/table/index/index
处理对象类型 schema_export/table/constraint/constraint
处理对象类型 schema_export/table/index/statistics/index_statistics
处理对象类型 schema_export/table/comment
处理对象类型 schema_export/table/constraint/ref_constraint
处理对象类型 schema_export/table/statistics/table_statistics
. . 导出了 scott.dept 5.656 kb 4 行
. . 导出了 scott.emp 7.820 kb 14 行
. . 导出了 scott.salgrade 5.585 kb 5 行
. . 导出了 scott.bonus 0 kb 0 行
已成功加载/卸载了主表 scott.my_job
******************************************************************************
scott.my_job 的转储文件集为:
d:\direxp\scott_not_e_begin.dmp
作业 scott.my_job 已于 17:58:31 成功完成
--导出scott用户下的所有对象,但是对于表类型只导出以e$开头的表:
expdp scott/scott@192.168.11.1:1521/orcl dumpfile=scott_e$_begin.dmp logfile=scott_e$_begin.dmp.log directory=dir_exp job_name=my_job exclude=table:\not like \'e$%\'\
c:\users\administrator>expdp scott/scott@192.168.11.1:1521/orcl dumpfile=scott_e
$_begin.dmp logfile=scott_e$_begin.dmp.log directory=dir_exp job_name=my_job exc
lude=table:\not like \'e$%\'\
export: release 10.2.0.1.0 - production on 星期一, 27 10月, 2014 18:00:13
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
启动 scott.my_job: scott/********@192.168.11.1:1521/orcl dumpfile=scott_e$_
begin.dmp logfile=scott_e$_begin.dmp.log directory=dir_exp job_name=my_job exclu
de=table:not like \'e$%\'
正在使用 blocks 方法进行估计...
处理对象类型 schema_export/table/table_data
使用 blocks 方法的总估计: 0 kb
处理对象类型 schema_export/pre_schema/procact_schema
已成功加载/卸载了主表 scott.my_job
******************************************************************************
scott.my_job 的转储文件集为:
d:\direxp\scott_e$_begin.dmp
作业 scott.my_job 已于 18:00:25 成功完成
--dba导出所有数据
expdp system/root directory=dir_exp dumpfile=super.dmp full=y
impdp介绍
数据泵导出导入(expdp和impdp)的作用
1、实现逻辑备份和逻辑恢复。
2、在数据库用户之间移动对象。
3、在数据库之间移动对象
4、实现表空间搬移。 数据泵导出导入与传统导出导入的区别:
impdp命令行选项与expdp有很多相同的,不同的有:
1、remap_datafile
该选项用于将源数据文件名转变为目标数据文件名,在不同平台之间搬移表空间时可能需要该选项.
remap_datafiel=source_datafie:target_datafile
2、remap_schema
该选项用于将源方案的所有对象装载到目标方案中.
remap_schema=source_schema:target_schema
3、remap_tablespace
将源表空间的所有对象导入到目标表空间中
remap_tablespace=source_tablespace:targettablespace
如果是多个表空间,则用逗号分开,如remap_tablespace=source_tablespace1:targettablespace1,source_tablespace2:targettablespace2
4、reuse_datafiles
该选项指定建立表空间时是否覆盖已存在的数据文件.默认为n
reuse_datafiels={y | n}
5、skip_unusable_indexes
指定导入是是否跳过不可使用的索引,默认为n
6、sqlfile
指定将导入要指定的索引ddl操作写入到sql脚本中
sqlfile=[directory_object:]file_name
impdp scott/tiger directory=dump dumpfile=tab.dmp sqlfile=a.sql
7、streams_configuration
指定是否导入流元数据(stream matadata),默认值为y.
8、table_exists_action
该选项用于指定当表已经存在时导入作业要执行的操作,默认为skip
tabble_exists_action={skip | append | truncate | frplace }
当设置该选项为skip时,导入作业会跳过已存在表处理下一个对象;当设置为append时,会追加数据,为truncate时,导入作业会截断表,然后为其追加新数据;当设置为replace时,导入作业会删除已存在表,重建表病追加数据,注意,truncate选项不适用与簇表和network_link选项
9、transform
该选项用于指定是否修改建立对象的ddl语句
transform=transform_name:value[:object_type]
transform_name用于指定转换名,其中segment_attributes用于标识段属性(物理属性,存储属性,表空间,日志等信息),storage用于标识段存储属性,value用于指定是否包含段属性或段存储属性,object_type用于指定对象类型.
impdp scott/tiger directory=dump dumpfile=tab.dmp transform=segment_attributes:n:table
10、transport_datafiles
该选项用于指定搬移空间时要被导入到目标数据库的数据文件
transport_datafile=datafile_name
datafile_name用于指定被复制到目标数据库的数据文件
impdp system/manager directory=dump dumpfile=tts.dmp
transport_datafiles=’/user01/data/tbs1.f’调用impdp
table_exists_action=replace:表如果存在,则替换
1、按表导入
hr_20141027.dmp文件中的表,此文件是以hr用户按schemas=hr导出的:
impdp hr_exp/hr_exp@192.168.11.1:1521/orcl dumpfile =hr_20141027.dmp logfile=hr_20141027.log directory=dir_exp remap_schema=hr:hr_exp exclude=statistics tables=hr.jobs job_name=my_job table_exists_action=replace
c:\users\administrator>impdp hr_exp/hr_exp@192.168.11.1:1521/orcl dumpfile =hr_2
0141027.dmp logfile=hr_20141027.log directory=dir_exp remap_schema=hr:hr_exp
exclude=statistics tables=hr.jobs job_name=my_job table_exists_action=replace
import: release 10.2.0.1.0 - production on 星期一, 27 10月, 2014 21:32:01
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.my_job
启动 hr_exp.my_job: hr_exp/********@192.168.11.1:1521/orcl dumpfile =hr_201
41027.dmp logfile=hr_20141027.log directory=dir_exp remap_schema=hr:hr_exp exclu
de=statistics tables=hr.jobs job_name=my_job table_exists_action=replace
处理对象类型 schema_export/table/table
处理对象类型 schema_export/table/table_data
. . 导入了 hr_exp.jobs 6.609 kb 19 行
处理对象类型 schema_export/table/grant/owner_grant/object_grant
处理对象类型 schema_export/table/index/index
处理对象类型 schema_export/table/constraint/constraint
处理对象类型 schema_export/table/comment
作业 hr_exp.my_job 已于 21:32:06 成功完成
2、按用户导入(可以将用户信息直接导入,即如果用户信息不存在的情况下也可以直接导入)
impdp hr_exp/hr_exp@192.168.11.1:1521/orcl schemas=hr dumpfile =hr_20141027.dmp logfile=hr_20141027.log directory=dir_exp job_name=my_job
c:\users\administrator>impdp hr_exp/hr_exp@192.168.11.1:1521/orcl schemas=hr du
mpfile =hr_20141027.dmp logfile=hr_20141027.log directory=dir_exp job_name=my_jo
b
import: release 10.2.0.1.0 - production on 星期一, 27 10月, 2014 21:33:29
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.my_job
启动 hr_exp.my_job: hr_exp/********@192.168.11.1:1521/orcl schemas=hr dumpf
ile =hr_20141027.dmp logfile=hr_20141027.log directory=dir_exp job_name=my_job
处理对象类型 schema_export/user
处理对象类型 schema_export/system_grant
处理对象类型 schema_export/role_grant
处理对象类型 schema_export/default_role
处理对象类型 schema_export/pre_schema/procact_schema
处理对象类型 schema_export/sequence/sequence
处理对象类型 schema_export/table/table
处理对象类型 schema_export/table/table_data
. . 导入了 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 行
处理对象类型 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_exp.my_job 已于 21:33:40 成功完成
3、不通过expdp的步骤生成dmp文件而直接导入的方法:
--从源数据库中向目标数据库导入表p_street_area
--远程数据库的操作代码
c:\documents and settings\administrator>expdp hr/hr@192.168.11.2:1521/orcl direc
tory=expdp_home dumpfile=hr_exp.dmp logfile=hr_exp.log
export: release 10.2.0.1.0 - production on 星期一, 27 10月, 2014 21:46:21
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.sys_export_schema_01: hr/********@192.168.11.2:1521/orcl directory=
expdp_home dumpfile=hr_exp.dmp logfile=hr_exp.log
正在使用 blocks 方法进行估计...
处理对象类型 schema_export/table/table_data
使用 blocks 方法的总估计: 448 kb
处理对象类型 schema_export/user
处理对象类型 schema_export/system_grant
处理对象类型 schema_export/role_grant
处理对象类型 schema_export/default_role
处理对象类型 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 6.085 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.sys_export_schema_01
******************************************************************************
hr.sys_export_schema_01 的转储文件集为:
d:\expdp_home\hr_exp.dmp
作业 hr.sys_export_schema_01 已于 21:46:54 成功完成c:\documents and settings\administrator>sqlplus / as sysdba
sql*plus: release 10.2.0.1.0 - production on 星期一 10月 27 21:42:09 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 or replace directory expdp_home as 'd:\expdp_home';
目录已创建。
sql> grant read,write on directory expdp_home to hr;
授权成功。
--从源数据库中向目标数据库导入表p_street_area
impdp gwm/gwm directory=dir_dp network_link=igisdb tables=p_street_area logfile=p_street_area.log job_name=my_job
igisdb是目的数据库与源数据的链接名,dir_dp是目的数据库上的目录
4、更换表空间
采用remap_tablespace参数
--导出gwm用户下的所有数据
expdp system/orcl directory=data_pump_dir dumpfile=gwm.dmp schemas=gwm
注:如果是用sys用户导出的用户数据,包括用户创建、授权部分,用自身用户导出则不含这些内容
--以下是将gwm用户下的数据全部导入到表空间gcomm(原来为gmapdata表空间下)下
impdp system/orcl directory=data_pump_dir dumpfile=gwm.dmp remap_tablespace=gmapdata:gcomm
查看目录权限
sql> select privilege, directory_name, directory_path from user_tab_privs t, all_directories d where t.table_name(+) = d.directory_name order by 2, 1;
其它类似信息

推荐信息