众所周知,IMP工具的FROMUSER和TOUSER参数可以实现将一个用户的的数据迁移到另外一个用户。同样的功能在IMPPDP工具中如何得以体现呢?
答案就是:使用IMPPDP的REMAP_SCHEMA参数实现。

简单演示一下,供参考。

任务:将sec用户中的数据迁移到secooler用户。

1.分别确认sec和secooler用户下的表和数据情况
1)sec用户下有一张T表,含有24360行数据
sys@ora10g> conn sec/sec
Connected.
sec@ora10g> select * from tab;

TNAME                          TABTYPE  CLUSTERID
------------------------------ ------- ----------
T                              TABLE

sec@ora10g> select count(*) from t;

COUNT(*)
----------
     24360

2)确认secooler用户不包含表T
secooler@ora10g> conn secooler/secooler
Connected.
secooler@ora10g> select * from tab;

no rows selected

2.创建目录对象expdp_dir
sys@ora10g> create or replace directory expdp_dir as '/expdp';

Directory created.

3.将目录对象expdp_dir的读写权限授权给sec和secooler用户
sys@ora10g> grant read,write on directory expdp_dir to sec;

Grant succeeded.

sys@ora10g> grant read,write on directory expdp_dir to secooler;

Grant succeeded.

4.生成sec的备份文件
ora10g@secDB /expdp$ expdp sec/sec directory=expdp_dir dumpfile=`date +"%Y%m%d%H%M%S"`_sec.dmp logfile=`date +"%Y%m%d%H%M%S"`_sec.log

Export: Release 10.2.0.3.0 - 64bit Production on Thursday, 01 April, 2010 10:29:17

Copyright (c) 2003, 2005, Oracle.  All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options
Starting "SEC"."SYS_EXPORT_SCHEMA_01":  sec/******** directory=expdp_dir dumpfile=20100401102917_sec.dmp logfile=20100401102917_sec.log
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 3 MB
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/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/COMMENT
. . exported "SEC"."T"                                   2.259 MB   24360 rows
Master table "SEC"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SEC.SYS_EXPORT_SCHEMA_01 is:
  /expdp/20100401102917_sec.dmp
Job "SEC"."SYS_EXPORT_SCHEMA_01" successfully completed at 10:29:20

生成的备份文件信息如下:
ora10g@secDB /expdp$ ls -l *sec.dmp
-rw-r----- 1 oracle oinstall 2.5M Apr  1 10:29 20100401102917_sec.dmp

5.使用IMPDP的REMAP_SCHEMA参数实现secooler用户的数据导入
ora10g@secDB /expdp$ impdp secooler/secooler directory=expdp_dir dumpfile=20100401102917_sec.dmp logfile=20100401102917_sec_impdp.log REMAP_SCHEMA=sec:secooler

Import: Release 10.2.0.3.0 - 64bit Production on Thursday, 01 April, 2010 10:32:10

Copyright (c) 2003, 2005, Oracle.  All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options
Master table "SECOOLER"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting "SECOOLER"."SYS_IMPORT_FULL_01":  secooler/******** directory=expdp_dir dumpfile=20100401102917_sec.dmp logfile=20100401102917_sec_impdp.log REMAP_SCHEMA=sec:secooler
Processing object type SCHEMA_EXPORT/USER
ORA-31684: Object type USER:"SECOOLER" 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 "SECOOLER"."T"                              2.259 MB   24360 rows
Job "SECOOLER"."SYS_IMPORT_FULL_01" completed with 1 error(s) at 10:32:12

OK,迁入任务完成。

6.确认最后的迁移迁移成果
连接到secooler用户确认T表及其中的数据是否已经完成导入。
sec@ora10g> conn secooler/secooler
Connected.
secooler@ora10g> select * from tab;

TNAME                          TABTYPE  CLUSTERID
------------------------------ ------- ----------
T                              TABLE

secooler@ora10g> select count(*) from t;

COUNT(*)
----------
     24360

OK,搞定。

7.进一步参考资料
最好的参考资料就是Oracle的官方文档,参考链接如下:
http://download.oracle.com/docs/cd/B19306_01/server.102/b14215/dp_import.htm#sthref340
便于参考,copy一份在此:
REMAP_SCHEMA

Default: none

Purpose

Loadsall objects from the source schema into a target schema.

Syntax and Description

REMAP_SCHEMA=source_schema:target_schema

MultipleREMAP_SCHEMAlines can be specified, but the source schema must be different for each one. However, different source schemas can map to the same target schema. The mapping may not be 100 percent complete, because there are certain schema references that Import is not capable of finding. For example, Import will not find schema references ××ded within the body of definitions of types, views, procedures, and packages.

If the schema you are remapping to does not already exist, the import operation creates it, provided the dump file set contains the necessaryCREATEUSERmetadata for the source schema and you are importing with enough privileges. For example, the following Export commands would create the dump file sets with the necessary metadata to create a schema, because the userSYSTEMhas the necessary privileges:

> expdp SYSTEM/passwordSCHEMAS=hr
> expdp SYSTEM/passwordFULL=y

If your dump file set does not contain the metadata necessary to create a schema, or if you do not have privileges, then the target schema must be created before the import operation is performed. This is because the unprivileged dump files do not contain the necessary information for the import to create the schema automatically.

If the import operation does create the schema, then after the import is complete, you must assign it a valid password in order to connect to it. The SQL statement to do this, which requires privileges, is:

SQL> ALTER USER [schema_name] IDENTIFIED BY [new_pswd]

Restrictions

Unprivileged users can perform. schema remaps only if their schema is the target schema of the remap. (Privileged users can perform. unrestricted schema remaps.)

For example,SCOTTcan remap hisBLAKE's objects toSCOTT, butSCOTTcannot remapSCOTT's objects toBLAKE.

Example

Suppose that you execute the following Export and Import commands to remap thehrschema into thescottschema:

> expdp SYSTEM/passwordSCHEMAS=hr DIRECTORY=dpump_dir1 DUMPFILE=hr.dmp

> impdp SYSTEM/passwordDIRECTORY=dpump_dir1 DUMPFILE=hr.dmp
REMAP_SCHEMA=hr:scott

In this example, if userscottalready exists before the import, then the ImportREMAP_SCHEMAcommand will add objects from thehrschema into the existingscottschema. You can connect to thescottschema after the import by using the existing password (without resetting it).

If userscottdoes not exist before you execute the import operation, Import automatically creates it with an unusable password. This is possible because the dump file,hr.dmp, was created bySYSTEM,which has the privileges necessary to create a dump file that contains the metadata needed to create a schema. However, you cannot connect toscotton completion of the import, unless you reset the password forscotton the target database after the import completes.
8.小结
在从EXP备份工具转到EXPDP工具的过程中,有很多的变动一定要注意,防止因误用导致效率低下。
无论是从功能上还是效率上讲,EXPDP都是首选(需要在服务器端使用)。

Good luck.

oracle_11g 不同用户之间的数据迁移的更多相关文章

  1. 阿里云RDS实例内不同数据库之间的数据迁移

    适用场景 本文适用于使用DTS实现相同实例下库名不同的数据库之间的数据迁移.本文以使用DTS将同一RDS实例下的amptest库迁移到jiangliu_amptest库为例来说明如何使用DTS实现相同 ...

  2. 利用Kettle进行SQLServer与Oracle之间的数据迁移实践

    Kettle简介 Kettle(网地址为http://kettle.pentaho.org/)是一款国外开源的ETL工具,纯java编写,可以在Windows.Linux.Unix上运行,数据抽取高效 ...

  3. 生产环境下,oracle不同用户间的数据迁移。第一部分

    :任务名称:生产环境下schema ELON数据迁移至schema TIAN ######################################## 测试一:测试参数 数据泵数据导出:exp ...

  4. 生产环境下,oracle不同用户间的数据迁移。第二部分

    任务名称:生产环境下schema ELON数据迁移至schema TIAN######################################## 测试二:测试参数remap_tablespa ...

  5. 生产环境下,oracle不同用户间的数据迁移。第三部分

    任务名称:生产环境下schema ELON数据迁移至schema TIAN########################################前期准备:1:确认ELON用户下的对象状态se ...

  6. dblink实现不同用户之间的数据表访问

    1.dblink 1.创建dblink,如果在用户A下创建dblink,名称为TEST_DBLINK; 去操作GCFR_33用户下的表数据等等, 那么在查询表数据的sql就要加上dblink了.如下是 ...

  7. Oracle同一数据库实例不同用户间的数据迁移

    1.目标用户登录,创建自我连接的DB LINK -- Create database link create public database link MYLINK connect to 原用户名 u ...

  8. 阿里云 RDS实例间的数据迁移

    使用数据传输DTS可以实现两个RDS实例间的数据迁移.对于支持增量迁移的存储引擎,还可以使用DTS在源RDS实例不停服的情况下,将数据迁移到目标RDS实例.目前对于RDS不同存储引擎,只支持同构迁移( ...

  9. SQL SERVER几种数据迁移/导出导入的实践

    SQLServer提供了多种数据导出导入的工具和方法,在此,分享我实践的经验(只涉及数据库与Excel.数据库与文本文件.数据库与数据库之间的导出导入). (一)数据库与Excel 方法1: 使用数据 ...

随机推荐

  1. 使用curl下载文件

    curl是一个非常好的网络传输库,使用也很简单.常用的使用方式是用它来下载资源文件,以下提供一个下载方法 #include <stdio.h> #include <iostream. ...

  2. Trie树模板~~~

    * + ; ; // 字母表为全体小写字母的Trie struct Trie { int ch[maxnode][sigma_size]; int val[maxnode]; int sz; // 结 ...

  3. Jquery zTree的使用

    <%@ page language="java" pageEncoding="utf-8"%><%@taglib prefix="s ...

  4. iOS Xcode的快捷键

    将一些搜集和经常使用的快捷键记录下来,方便你我. Command +1~ 8: 跳转到导航区的不同位置 Command +0 :显示/隐藏导航区 Command Alt 1~ 6:在不同检测器之间跳转 ...

  5. javascript中bind,apply,call的相同和不同之处

    javasctipt中bind,apply,call的相同点是: 1,都是用来改变this的指向; 2,都可以通过后续参数进行传参; 3,第一个参数都是指定this要指向的对象; 不同点: 1,调用方 ...

  6. ActiveMQ, Qpid, HornetQ and RabbitMQ in Comparison

    国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html内部邀请码:C8E245J (不写邀请码,没有现金送)国内私 ...

  7. Android FM模块学习之二 FM搜索频率流程

    上一篇大概分析了一下FM启动流程,若不了解Fm启动流程的,能够去打开前面的链接先了解FM启动流程,接下来我们简单分析一下FM的搜索频率流程. 在了解源代码之前.我们先看一下流程图: 事实上从图中能够看 ...

  8. Rational Rose 2007 &amp;Rational Rose 2003 下载及破解方法和汉化文件下载

    这么好的东西,不拿来出分享,我对不起原作者呀.可是我这里不知道作者是谁,感谢在先了. ed2k://|file|%5BIBM%E8%BD%AF%E4%BB%B6%E7%B3%BB%E5%88%97%5 ...

  9. SIGGRAPH

    这两天看了一些文章,今天来说说SIGGRAPH. 对于搞图形学的人来说,SIGGRAPH绝对是如雷贯耳.SIGGRAPH是计算机图形界(也包含图像)最顶级的会议,没有之中的一个,是全世界的图形学者公认 ...

  10. Android-ViewPagerIndicator

    https://github.com/JakeWharton/Android-ViewPagerIndicator