众所周知,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. qtcreator 与 opencv

    参考: http://blog.csdn.net/skeeee/article/details/10585429

  2. [CCC 1996 01]Deficient, Perfect, and Abundant

    CCC加拿大高中生信息学奥赛 其余来源 CODEVS[3312]——CCC 1996 01 Deficient, Perfect, and Abundant ——http://codevs.cn/pr ...

  3. [TYVJ1827]『Citric II』一道防AK好题

    时间: 1000ms / 空间: 131072KiB / Java类名: Main 背景 第二届『Citric杯』NOIP提高组模拟赛第一题 描述 Lemon认为在第一届『Citric』杯模拟赛中出的 ...

  4. c#文件转化byte数组

    public static byte[] ReadFile(string fileName) { if (!File.Exists(fileName)) { throw new Exception(& ...

  5. 小波变换和motion信号处理(一)(转)

    写的太好,不得不转:http://www.kunli.info/2011/02/15/fourier-wavelet-motion-signal-1/ 这是<小波变换和motion信号处理> ...

  6. mongrel

    Mongrel是一种快速的针对Ruby的Http 服务器,专门为部署发布rails应用而产生的. 可以替代mod_ruby/fastcgi,可以用于生产部属环境. 支持集群,扩展性强. 有各种丰富插件 ...

  7. IE-首页跳转到 q160的问题解决

    IE首页跳转到 q160的问题解决­ 服了又中找了,IE快捷方式被 www.q160.com劫持­ 该死的这个网站什么也没有做,就是做了一个google搜索的连接.­ ­ 进行了一次搜索­ http: ...

  8. [六]JFreeChart实践五之与Struts2整合

    1.Action,返回Chart package com.java1234.chart.bar; import java.awt.Color; import org.jfree.chart.Chart ...

  9. opencl 在vs2015上遇见的问题

    严重性 代码 说明 项目 文件 行 禁止显示状态 错误 C4996 'clCreateCommandQueue': 被声明为已否决 Project2 d:... 解决方法:#pragma warnin ...

  10. S2SH商用后台权限系统第三讲

    个位博友: 您好!今天我们做下登录页面,已经如何登录系统.我们的登录页面很简单,用户名.密码.验证码.下面首先描述下验证码的概念,验证码是为了防止机器人恶意登录.我们这里的验证码采用4位数字,当然你也 ...