数据泵导入导出表

来源:互联网 发布:linux 同步文件 sync 编辑:程序博客网 时间:2024/04/29 14:55

将 HHN库下 SCOTT 用户的 EMP 表和 DEPT 表导入到 HHN库下 TUSER 用户下。
1、 将 SCOTT 用户的 EMP 表和 DEPT 表导出:
在 SCOTT 用户下创建导出的目录:
create or replace directory exp_file_dest as ‘E:\USER_DEST’;
2、在CMD下执行:
expdp scott/oracle@HHN tables=EMP,DEPT directory=EXP_FILE_DEST dumpfile=scott_emp_dept_20161230.dmp
(dumpfile 参数是指定导出的文件名。)
3、创建TUSR用户
create user tuser identified by tuser;
Tuser 用户要导入文件到数据库,因此 tuser 必须要有以下权限:
①、 connect 权限
②、 resource 权限
③、 对目录的读写权限。
④、创建目录的权限,在tuser下也必须要有exp_file_dest这个目录

如果要导入的是其他数据库,那么其他数据库中并没有目录对象: EXP_FILE_DEST。假设我要从 HMN 库导入
到 HMN 库,那么我必须在 HMN 库建立一个 DIRECTORY,把要导入的文件放到该目录下。
授权命令:

grant connect to tuser;
grant resource to tuser;
grant CREATE ANY DIRECTORY to tuser;
grant read,write on directory EXP_FILE_DEST to tuser;
4、在CMD下执行导入命令:
impdp tuser/tuser@HHN directory=EXP_FILE_DEST dumpfile=SCOTT_EMP_DEPT_20161230.DMP

这个时候报了错误
ORA-31655: 尚未为作业选择数据或元数据对象
解决的方法:
impdp system directory=EXP_FILE_DEST dumpfile=SCOTT_EMP_DEPT_20161230.DMP remap_schema=scott:tuser tables=SCOTT.EMP,SCOTT.DEPT
查看结果:

C:\Users\Administrator>impdp system directory=EXP_FILE_DEST dumpfile=SCOTT_EMP_DEPT_20161230.DMP remap_schema=scott:tuser tables=SCOTT.EMP,SCOTT.DEPT

Import: Release 11.2.0.1.0 - Production on 星期五 12月 30 16:24:10 2016

Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
口令:(scott的密码)

连接到: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
已成功加载/卸载了主表 “SYSTEM”.”SYS_IMPORT_TABLE_01”
启动 “SYSTEM”.”SYS_IMPORT_TABLE_01”: system/** directory=EXP_FILE_DEST dumpfile=SCOTT_EMP_DEPT_20161230.DMP remap_schema=scott:tuser tables=SCOTT.EMP,SC
OTT.DEPT
处理对象类型 TABLE_EXPORT/TABLE/TABLE
处理对象类型 TABLE_EXPORT/TABLE/TABLE_DATA
. . 导入了 “TUSER”.”DEPT” 5.890 KB 4 行
. . 导入了 “TUSER”.”EMP” 8.335 KB 14 行
处理对象类型 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
作业 “SYSTEM”.”SYS_IMPORT_TABLE_01” 已于 16:24:28 成功完成
登录到TUSER用户
这里写图片描述

0 0
原创粉丝点击