Oracle   发布时间:2022-05-17  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Oracle简单常用的数据泵导出导入(expdp/impdp)命令举例(下)大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

转载自:http://www.cnblogs.com/jyzhao/p/4530575.html

目的:指导项目侧自行进行简单的数据泵迁移工作。

本文实验环境:Oracle 11.2.0.4,利用数据库自带的scott示例用户进行试验测试。
根据《简单常用的数据泵导出导入(expdp/impdp)命令举例(上)》的expdp导出的二进制文件进行impdp导入。

1.首先需要创建Directory

2.创建表空间和用户及赋权

3.使用impdp导入用户数据

3.1 导入scott用户的元数据,且不包含统计信息;
3.2 导入scott用户的数据;
3.3 导入scott用户下的emp,dept表及数据;
3.4 导入scott用户下的emp,dept表结构;
3.5 导入scott用户下所有的内容;
3.6 并行导入scott用户下所有的内容;
4. 特殊需求

4.1 如果导入环境的用户不同;
4.2 如果导入环境的表空间也不同;

由于我这里的实验环境还是导出的那台主机,所以需要先模拟出一个导入的环境,你实际导入并不需要。

1.删除scott用户;

drop user scott cascade;

2.删除users表空间。

drop tablespace users including contents and datafiles;

可能users表空间是默认的数据库表空间,导致删除失败,只需要更改下再执行删除即可。

select a.property_name,a.property_value from database_propertIEs a where a.property_name like '%DEFAulT%';
alter database default tablespace DBS_D_XXX;

这样就模拟出了一个没有users表空间和scott用户的崭新环境。

1. 首先需要创建Directory

这里目录名字定义为”jy”,
若是windows平台,对应系统目录为”E:\jingyu”;

create or replace directory jy as 'E:\jingyu';

若是Unix/linux平台,对应系统目录为”/tmp/jingyu”.

create or replace directory jy as '/tmp/jingyu';

注意:目录在系统上需要真实存在(mkdir -p /tmp/jingyu),且有访问的权限。
drwxr-xr-x. 2 oracle oinstall 4.0K May 22 16:48 jingyu

2. 创建表空间和用户及赋权

create tablespace users datafile '+data1' size 10M autoextend on maxsize 30G;
create user scott IDentifIEd by tiger default tablespace users;
grant connect,resource to scott;
grant read,write on directory jy to scott;

3. 使用impdp导入用户数据

初始化环境:
初始1:得到删除当前用户下表的sql:select 'drop table '||table_name||' purge;' from user_tables;
初始2:得到查询当前用户下表的数据量:select 'select count(1) from '||table_name||';' from user_tables;

3.1 导入scott用户的元数据,且不包含统计信息;

impdp system directory=jy dumpfile=scott_Meta.dmp logfile=impdp_scott_Meta.log

$ impdp system directory=jy dumpfile=scott_Meta.dmp logfile=impdp_scott_Meta.log

import: Release 11.2.0.4.0 - Production on Tue May 26 13:36:41 2015

copyright (c) 1982,2011,Oracle and/or its affiliates.  All rights reserved.
Password: 

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning,automatic Storage Management,olAP,Data Mining
and Real Application Testing options
Master table "SYstem"."SYS_import_FulL_01" successfully loaded/unloaded
Starting "SYstem"."SYS_import_FulL_01":  system/******** directory=jy dumpfile=scott_Meta.dmp logfile=impdp_scott_Meta.log 
Processing object type SCHEMA_EXPORT/USER
ORA-31684: Object type USER:"SCott" already exists
Processing object type SCHEMA_EXPORT/SYstem_GRANT
Processing object type SCHEMA_EXPORT/RolE_GRANT
Processing object type SCHEMA_EXPORT/DEFAulT_RolE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/table/table
Processing object type SCHEMA_EXPORT/table/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type SCHEMA_EXPORT/table/INDEX/INDEX
Processing object type SCHEMA_EXPORT/table/CONSTRAINT/CONSTRAINT
Job "SYstem"."SYS_import_FulL_01" completed with 1 error(s) at Tue May 26 13:36:49 2015 elapsed 0 00:00:03

3.2 导入scott用户的数据;

在3.1导入元数据后才可以导入数据。
impdp system directory=jy dumpfile=scott_data.dmp logfile=impdp_scott_data.log

$ impdp system directory=jy dumpfile=scott_data.dmp logfile=impdp_scott_data.log

import: Release 11.2.0.4.0 - Production on Tue May 26 13:39:15 2015

copyright (c) 1982,Oracle and/or its affiliates.  All rights reserved.
Password: 

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning,Data Mining
and Real Application Testing options
Master table "SYstem"."SYS_import_FulL_01" successfully loaded/unloaded
Starting "SYstem"."SYS_import_FulL_01":  system/******** directory=jy dumpfile=scott_data.dmp logfile=impdp_scott_data.log 
Processing object type SCHEMA_EXPORT/table/table_DATA
. . imported "SCott"."DEPT"                              5.929 KB       4 rows
. . imported "SCott"."EMP"                               8.484 KB      12 rows
. . imported "SCott"."SALGRADE"                          5.859 KB       5 rows
. . imported "SCott"."BONUS"                                 0 KB       0 rows
Job "SYstem"."SYS_import_FulL_01" successfully completed at Tue May 26 13:39:26 2015 elapsed 0 00:00:07

3.3 只导入scott用户下的emp表及数据;

这里为了演示导入,先初始化删除scott用户下的所有表。

impdp scott directory=jy tables=emp dumpfile=scott_emp_dept.dmp logfile=impdp_scott_emp.log

$ impdp scott directory=jy tables=emp dumpfile=scott_emp_dept.dmp logfile=impdp_scott_emp.log

import: Release 11.2.0.4.0 - Production on Tue May 26 13:50:51 2015

copyright (c) 1982,Data Mining
and Real Application Testing options
Master table "SCott"."SYS_import_table_01" successfully loaded/unloaded
Starting "SCott"."SYS_import_table_01":  scott/******** directory=jy tables=emp dumpfile=scott_emp_dept.dmp logfile=impdp_scott_emp.log 
Processing object type table_EXPORT/table/table
Processing object type table_EXPORT/table/table_DATA
. . imported "SCott"."EMP"                               8.484 KB      12 rows
Processing object type table_EXPORT/table/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type table_EXPORT/table/INDEX/INDEX
Processing object type table_EXPORT/table/CONSTRAINT/CONSTRAINT
Processing object type table_EXPORT/table/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type table_EXPORT/table/STATISTICS/table_STATISTICS
Job "SCott"."SYS_import_table_01" successfully completed at Tue May 26 13:50:59 2015 elapsed 0 00:00:03

3.4 只导入scott用户下的emp,dept表结构;

这里为了演示导入,先初始化删除scott用户下的所有表。

impdp scott directory=jy tables=emp,dept dumpfile=scott_emp_dept_Meta.dmp logfile=impdp_scott_emp_dept_Meta.log

$ impdp scott directory=jy tables=emp,dept dumpfile=scott_emp_dept_Meta.dmp logfile=impdp_scott_emp_dept_Meta.log

import: Release 11.2.0.4.0 - Production on Tue May 26 13:54:38 2015

copyright (c) 1982,Data Mining
and Real Application Testing options
Master table "SCott"."SYS_import_table_01" successfully loaded/unloaded
Starting "SCott"."SYS_import_table_01":  scott/******** directory=jy tables=emp,dept dumpfile=scott_emp_dept_Meta.dmp logfile=impdp_scott_emp_dept_Meta.log 
Processing object type table_EXPORT/table/table
Processing object type table_EXPORT/table/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type table_EXPORT/table/INDEX/INDEX
Processing object type table_EXPORT/table/CONSTRAINT/CONSTRAINT
Processing object type table_EXPORT/table/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type table_EXPORT/table/STATISTICS/table_STATISTICS
Job "SCott"."SYS_import_table_01" successfully completed at Tue May 26 13:54:45 2015 elapsed 0 00:00:03

由于导出就是emp,dept两张表,所以也可以不指定tables,以下两种写法在这里都是可以的:
impdp scott directory=jy dumpfile=scott_emp_dept_Meta.dmp logfile=impdp_scott_emp_dept_Meta.log

impdp scott directory=jy dumpfile=scott_emp_dept_Meta.dmp logfile=impdp_scott_emp_dept_Meta.log full=y

3.5 导入scott用户下所有的内容;

impdp system directory=jy schemas=scott dumpfile=scott_all.dmp logfile=impdp_scott_all.log

如果是在2.4基础上直接导入,会因为emp,dept表已经存在导致导入过程中会由于table_exists_action参数的默认选项是skip,从而跳过emp,dept表数据的导入,如下:

$ impdp system directory=jy schemas=scott dumpfile=scott_all.dmp logfile=impdp_scott_all.log

import: Release 11.2.0.4.0 - Production on Tue May 26 14:22:50 2015

copyright (c) 1982,Data Mining
and Real Application Testing options
Master table "SYstem"."SYS_import_SCHEMA_01" successfully loaded/unloaded
Starting "SYstem"."SYS_import_SCHEMA_01":  system/******** directory=jy schemas=scott dumpfile=scott_all.dmp logfile=impdp_scott_all.log 
Processing object type SCHEMA_EXPORT/USER
ORA-31684: Object type USER:"SCott" already exists
Processing object type SCHEMA_EXPORT/SYstem_GRANT
Processing object type SCHEMA_EXPORT/RolE_GRANT
Processing object type SCHEMA_EXPORT/DEFAulT_RolE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/table/table
ORA-39151: table "SCott"."DEPT" exists. All dependent Metadata and data will be skipped due to table_exists_action of skip
ORA-39151: table "SCott"."EMP" exists. All dependent Metadata and data will be skipped due to table_exists_action of skip
Processing object type SCHEMA_EXPORT/table/table_DATA
. . imported "SCott"."SALGRADE"                          5.859 KB       5 rows
. . imported "SCott"."BONUS"                                 0 KB       0 rows
Processing object type SCHEMA_EXPORT/table/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type SCHEMA_EXPORT/table/INDEX/INDEX
Processing object type SCHEMA_EXPORT/table/CONSTRAINT/CONSTRAINT
Processing object type SCHEMA_EXPORT/table/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/table/STATISTICS/table_STATISTICS
Job "SYstem"."SYS_import_SCHEMA_01" completed with 3 error(s) at Tue May 26 14:22:57 2015 elapsed 0 00:00:03

所以这时我们想导入这些数据,可以加参数 table_exists_action,指定想要的选项。
table_EXISTS_ACTION
Action to take if imported object already exists.
ValID keywords are: APPEND,REPLACE,[SKIP] and TruncATE.

这里选择truncate,即如果表存在,那么处理方式是truncate此表后导入文件中包含的数据。
impdp system directory=jy schemas=scott table_exists_action=truncate dumpfile=scott_all.dmp logfile=impdp_scott_all.log

$ impdp system directory=jy schemas=scott table_exists_action=truncate dumpfile=scott_all.dmp logfile=impdp_scott_all.log import: Release 11.2.0.4.0 - Production on Tue May 26 14:26:09 2015 copyright (c) 1982,Oracle and/or its affiliates. All rights reserved. Password: Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning,Data Mining and Real Application Testing options Master table "SYstem"."SYS_import_SCHEMA_01" successfully loaded/unloaded Starting "SYstem"."SYS_import_SCHEMA_01": system/******** directory=jy schemas=scott table_exists_action=truncate dumpfile=scott_all.dmp logfile=impdp_scott_all.log Processing object type SCHEMA_EXPORT/USER ORA-31684: Object type USER:"SCott" already exists Processing object type SCHEMA_EXPORT/SYstem_GRANT Processing object type SCHEMA_EXPORT/RolE_GRANT Processing object type SCHEMA_EXPORT/DEFAulT_RolE Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA Processing object type SCHEMA_EXPORT/table/table table "SCott"."DEPT" exists and has been truncated. Data will be loaded but all dependent Metadata will be skipped due to table_exists_action of truncate table "SCott"."BONUS" exists and has been truncated. Data will be loaded but all dependent Metadata will be skipped due to table_exists_action of truncate table "SCott"."SALGRADE" exists and has been truncated. Data will be loaded but all dependent Metadata will be skipped due to table_exists_action of truncate table "SCott"."EMP" exists and has been truncated. Data will be loaded but all dependent Metadata will be skipped due to table_exists_action of truncate Processing object type SCHEMA_EXPORT/table/table_DATA . . imported "SCott"."DEPT" 5.929 KB 4 rows . . imported "SCott"."EMP" 8.484 KB 12 rows . . imported "SCott"."SALGRADE" 5.859 KB 5 rows . . imported "SCott"."BONUS" 0 KB 0 rows Processing object type SCHEMA_EXPORT/table/GRANT/OWNER_GRANT/OBJECT_GRANT Processing object type SCHEMA_EXPORT/table/INDEX/INDEX Processing object type SCHEMA_EXPORT/table/CONSTRAINT/CONSTRAINT Processing object type SCHEMA_EXPORT/table/INDEX/STATISTICS/INDEX_STATISTICS Processing object type SCHEMA_EXPORT/table/STATISTICS/table_STATISTICS Job "SYstem"."SYS_import_SCHEMA_01" completed with 1 error(s) at Tue May 26 14:26:17 2015 elapsed 0 00:00:04

注意:如果这里选用append选项,那么如果原表有数据,且没有合理的约束条件,则可能导致数据的重复导入,所以,生产环境实际导入过程中一定要弄清楚数据的实际情况才能准确决定如何选用此参数的选项。
如下所示,SALGRADE表会出现5条重复数据:
impdp system directory=jy schemas=scott table_exists_action=append dumpfile=scott_all.dmp logfile=impdp_scott_all.log

$ impdp system directory=jy schemas=scott table_exists_action=append dumpfile=scott_all.dmp logfile=impdp_scott_all.log

import: Release 11.2.0.4.0 - Production on Tue May 26 14:28:27 2015

copyright (c) 1982,Data Mining
and Real Application Testing options
Master table "SYstem"."SYS_import_SCHEMA_01" successfully loaded/unloaded
Starting "SYstem"."SYS_import_SCHEMA_01":  system/******** directory=jy schemas=scott table_exists_action=append dumpfile=scott_all.dmp logfile=impdp_scott_all.log 
Processing object type SCHEMA_EXPORT/USER
ORA-31684: Object type USER:"SCott" already exists
Processing object type SCHEMA_EXPORT/SYstem_GRANT
Processing object type SCHEMA_EXPORT/RolE_GRANT
Processing object type SCHEMA_EXPORT/DEFAulT_RolE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/table/table
table "SCott"."DEPT" exists. Data will be appended to existing table but all dependent Metadata will be skipped due to table_exists_action of append
table "SCott"."BONUS" exists. Data will be appended to existing table but all dependent Metadata will be skipped due to table_exists_action of append
table "SCott"."SALGRADE" exists. Data will be appended to existing table but all dependent Metadata will be skipped due to table_exists_action of append
table "SCott"."EMP" exists. Data will be appended to existing table but all dependent Metadata will be skipped due to table_exists_action of append
Processing object type SCHEMA_EXPORT/table/table_DATA
ORA-31693: table data object "SCott"."DEPT" Failed to load/unload and is being skipped due to error:
ORA-00001: unique constraint (SCott.PK_DEPT) violated
ORA-31693: table data object "SCott"."EMP" Failed to load/unload and is being skipped due to error:
ORA-00001: unique constraint (SCott.BIN$ESfmGQ7ZSsLgU58JqMBQqw==$0) violated
. . imported "SCott"."SALGRADE"                          5.859 KB       5 rows
. . imported "SCott"."BONUS"                                 0 KB       0 rows
Processing object type SCHEMA_EXPORT/table/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type SCHEMA_EXPORT/table/INDEX/INDEX
Processing object type SCHEMA_EXPORT/table/CONSTRAINT/CONSTRAINT
Processing object type SCHEMA_EXPORT/table/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/table/STATISTICS/table_STATISTICS
Job "SYstem"."SYS_import_SCHEMA_01" completed with 3 error(s) at Tue May 26 14:28:34 2015 elapsed 0 00:00:03

3.6 并行导入scott用户下所有的内容;

impdp system directory=jy schemas=scott table_exists_action=replace dumpfile=scott_all%U.dmp logfile=impdp_scott_all.log parallel=2

这里对于已经存在的对象直接replace掉。

$ impdp system directory=jy schemas=scott table_exists_action=replace dumpfile=scott_all%U.dmp logfile=impdp_scott_all.log parallel=2 import: Release 11.2.0.4.0 - Production on Tue May 26 14:15:37 2015 copyright (c) 1982,Data Mining and Real Application Testing options Master table "SYstem"."SYS_import_SCHEMA_01" successfully loaded/unloaded Starting "SYstem"."SYS_import_SCHEMA_01": system/******** directory=jy schemas=scott table_exists_action=replace dumpfile=scott_all%U.dmp logfile=impdp_scott_all.log parallel=2 Processing object type SCHEMA_EXPORT/USER ORA-31684: Object type USER:"SCott" already exists Processing object type SCHEMA_EXPORT/SYstem_GRANT Processing object type SCHEMA_EXPORT/RolE_GRANT Processing object type SCHEMA_EXPORT/DEFAulT_RolE Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA Processing object type SCHEMA_EXPORT/table/table Processing object type SCHEMA_EXPORT/table/table_DATA . . imported "SCott"."DEPT" 5.929 KB 4 rows . . imported "SCott"."EMP" 8.484 KB 12 rows . . imported "SCott"."SALGRADE" 5.859 KB 5 rows . . imported "SCott"."BONUS" 0 KB 0 rows Processing object type SCHEMA_EXPORT/table/GRANT/OWNER_GRANT/OBJECT_GRANT Processing object type SCHEMA_EXPORT/table/INDEX/INDEX Processing object type SCHEMA_EXPORT/table/CONSTRAINT/CONSTRAINT Processing object type SCHEMA_EXPORT/table/INDEX/STATISTICS/INDEX_STATISTICS Processing object type SCHEMA_EXPORT/table/STATISTICS/table_STATISTICS Job "SYstem"."SYS_import_SCHEMA_01" completed with 1 error(s) at Tue May 26 14:15:46 2015 elapsed 0 00:00:05

4. 特殊需求

特殊需求环境准备:
创建表空间users2:

create tablespace users2 datafile '+data1' size 10M autoextend on maxsize 30G;

创建用户scott2:

create user scott2 IDentifIEd by tiger default tablespace users2;

赋权用户scott2:

grant connect,resource to scott2;

4.1 如果导入环境的用户不同;

需求:将原scott用户的数据导入到现在的scott2用户。
impdp system directory=jy schemas=scott REMAP_SCHEMA=scott:scott2 table_exists_action=replace dumpfile=scott_all%U.dmp logfile=impdp_scott_all.log parallel=2

$ impdp system directory=jy schemas=scott REMAP_SCHEMA=scott:scott2 table_exists_action=replace dumpfile=scott_all%U.dmp logfile=impdp_scott_all.log parallel=2 import: Release 11.2.0.4.0 - Production on Tue May 26 14:55:02 2015 copyright (c) 1982,Data Mining and Real Application Testing options Master table "SYstem"."SYS_import_SCHEMA_01" successfully loaded/unloaded Starting "SYstem"."SYS_import_SCHEMA_01": system/******** directory=jy schemas=scott REMAP_SCHEMA=scott:scott2 table_exists_action=replace dumpfile=scott_all%U.dmp logfile=impdp_scott_all.log parallel=2 Processing object type SCHEMA_EXPORT/USER ORA-31684: Object type USER:"SCott2" already exists Processing object type SCHEMA_EXPORT/SYstem_GRANT Processing object type SCHEMA_EXPORT/RolE_GRANT Processing object type SCHEMA_EXPORT/DEFAulT_RolE Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA Processing object type SCHEMA_EXPORT/table/table Processing object type SCHEMA_EXPORT/table/table_DATA . . imported "SCott2"."DEPT" 5.929 KB 4 rows . . imported "SCott2"."EMP" 8.484 KB 12 rows . . imported "SCott2"."SALGRADE" 5.859 KB 5 rows . . imported "SCott2"."BONUS" 0 KB 0 rows Processing object type SCHEMA_EXPORT/table/GRANT/OWNER_GRANT/OBJECT_GRANT Processing object type SCHEMA_EXPORT/table/INDEX/INDEX Processing object type SCHEMA_EXPORT/table/CONSTRAINT/CONSTRAINT Processing object type SCHEMA_EXPORT/table/INDEX/STATISTICS/INDEX_STATISTICS Processing object type SCHEMA_EXPORT/table/STATISTICS/table_STATISTICS Job "SYstem"."SYS_import_SCHEMA_01" completed with 1 error(s) at Tue May 26 14:55:09 2015 elapsed 0 00:00:04

4.2 如果导入环境的表空间也不同;

需求:将原users表空间的对象重定向到users2表空间。
impdp system directory=jy schemas=scott REMAP_SCHEMA=scott:scott2 REMAP_tableSPACE=users:users2 table_exists_action=replace dumpfile=scott_all%U.dmp logfile=impdp_scott_all.log parallel=2

$ impdp system directory=jy schemas=scott REMAP_SCHEMA=scott:scott2 REMAP_tableSPACE=users:users2 table_exists_action=replace dumpfile=scott_all%U.dmp logfile=impdp_scott_all.log parallel=2 import: Release 11.2.0.4.0 - Production on Tue May 26 14:57:20 2015 copyright (c) 1982,Data Mining and Real Application Testing options Master table "SYstem"."SYS_import_SCHEMA_01" successfully loaded/unloaded Starting "SYstem"."SYS_import_SCHEMA_01": system/******** directory=jy schemas=scott REMAP_SCHEMA=scott:scott2 REMAP_tableSPACE=users:users2 table_exists_action=replace dumpfile=scott_all%U.dmp logfile=impdp_scott_all.log parallel=2 Processing object type SCHEMA_EXPORT/USER ORA-31684: Object type USER:"SCott2" already exists Processing object type SCHEMA_EXPORT/SYstem_GRANT Processing object type SCHEMA_EXPORT/RolE_GRANT Processing object type SCHEMA_EXPORT/DEFAulT_RolE Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA Processing object type SCHEMA_EXPORT/table/table Processing object type SCHEMA_EXPORT/table/table_DATA . . imported "SCott2"."DEPT" 5.929 KB 4 rows . . imported "SCott2"."EMP" 8.484 KB 12 rows . . imported "SCott2"."SALGRADE" 5.859 KB 5 rows . . imported "SCott2"."BONUS" 0 KB 0 rows Processing object type SCHEMA_EXPORT/table/GRANT/OWNER_GRANT/OBJECT_GRANT Processing object type SCHEMA_EXPORT/table/INDEX/INDEX Processing object type SCHEMA_EXPORT/table/CONSTRAINT/CONSTRAINT Processing object type SCHEMA_EXPORT/table/INDEX/STATISTICS/INDEX_STATISTICS Processing object type SCHEMA_EXPORT/table/STATISTICS/table_STATISTICS Job "SYstem"."SYS_import_SCHEMA_01" completed with 1 error(s) at Tue May 26 14:57:29 2015 elapsed 0 00:00:05

细心的朋友,会发现导入的日志最后都提示有一个错误,往上查发现是报错ORA-31684用户已存在,这是因为我们习惯在导入前建立好对应的用户,避免一些其他的权限错误,所以这个错误是可以忽略的。
当然其实如果我们已经建立了对应的表空间,用户也是可以不事先建立的,比如:
我们这里的情景,如果只事先建立users2表空间,不建立scott2用户,也是可以成功导入且不会有任何报错提示。

$ impdp system directory=jy schemas=scott REMAP_SCHEMA=scott:scott2 REMAP_tableSPACE=users:users2 table_exists_action=replace dumpfile=scott_all%U.dmp logfile=impdp_scott_all.log parallel=2 import: Release 11.2.0.4.0 - Production on Tue May 26 15:03:33 2015 copyright (c) 1982,Data Mining and Real Application Testing options Master table "SYstem"."SYS_import_SCHEMA_01" successfully loaded/unloaded Starting "SYstem"."SYS_import_SCHEMA_01": system/******** directory=jy schemas=scott REMAP_SCHEMA=scott:scott2 REMAP_tableSPACE=users:users2 table_exists_action=replace dumpfile=scott_all%U.dmp logfile=impdp_scott_all.log parallel=2 Processing object type SCHEMA_EXPORT/USER Processing object type SCHEMA_EXPORT/SYstem_GRANT Processing object type SCHEMA_EXPORT/RolE_GRANT Processing object type SCHEMA_EXPORT/DEFAulT_RolE Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA Processing object type SCHEMA_EXPORT/table/table Processing object type SCHEMA_EXPORT/table/table_DATA . . imported "SCott2"."DEPT" 5.929 KB 4 rows . . imported "SCott2"."EMP" 8.484 KB 12 rows . . imported "SCott2"."SALGRADE" 5.859 KB 5 rows . . imported "SCott2"."BONUS" 0 KB 0 rows Processing object type SCHEMA_EXPORT/table/GRANT/OWNER_GRANT/OBJECT_GRANT Processing object type SCHEMA_EXPORT/table/INDEX/INDEX Processing object type SCHEMA_EXPORT/table/CONSTRAINT/CONSTRAINT Processing object type SCHEMA_EXPORT/table/INDEX/STATISTICS/INDEX_STATISTICS Processing object type SCHEMA_EXPORT/table/STATISTICS/table_STATISTICS Job "SYstem"."SYS_import_SCHEMA_01" successfully completed at Tue May 26 15:03:42 2015 elapsed 0 00:00:05

大佬总结

以上是大佬教程为你收集整理的Oracle简单常用的数据泵导出导入(expdp/impdp)命令举例(下)全部内容,希望文章能够帮你解决Oracle简单常用的数据泵导出导入(expdp/impdp)命令举例(下)所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: