oracle remap语句格式,impdp 中的remap方式

oracle remap语句格式,impdp 中的remap方式impdp 中的 remap 方式 impdp 中要是没有 remap 方式 那么个人认为 datapump 将是一个死板的工具 remap table 方式语法格式 REMAP TABLE schema old tablename partition new tablename 在 hr 模式中根据 employees 创建如下一张表 SQL gt createtablee

impdp 中的remap方式

impdp 中要是没有remap方式,那么个人认为datapump 将是一个死板的工具。

remap_table方式

语法格式:REMAP_TABLE=[schema.]old_tablename[.partition]:new_tablename

在hr 模式中根据employees 创建如下一张表。

SQL>create table emp as select * from employees where 1=2;

执行导入操作,tables 中指定了employees,因为dumpfile table.dmp

中除了employees 表中的数据以外,还有其他表的数据。关键是remap_table

参数的使用把employees 表中的数据从映射到emp 表,并且我们还使用了

conntent=data_only 参数,因为emp表已经存在,我们需要导入的只是数据。

C:\Users\hello>impdp hr/hr tables=employees remap_table=employees:emp dumpfile=dmp_dir:table.dmp nologfile=yes content=data_only

Import: Release 11.2.0.1.0 – Production on Sun Jun 24 09:35:22 2012

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 – Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

Master table “HR”.”SYS_IMPORT_TABLE_01″ successfully loaded/unloaded

Starting “HR”.”SYS_IMPORT_TABLE_01″:  hr/ tables=employees remap_table=employees:emp dumpfile=dmp_dir:table.dmp nologfile=yes content=data_only

Processing object type TABLE_EXPORT/TABLE/TABLE_DATA

. . imported “HR”.”EMP”                                  16.80 KB     107 rows

Job “HR”.”SYS_IMPORT_TABLE_01″ successfully completed at 09:35:26

导入成功,下面确定数据是否存在于remap_table 参数指定的表中。

SQL>select count(*) from emp;

COUNT(*)

———-

107

remap_schema方式

语法格式:REMAP_SCHEMA=source_schema:target_schema

我们需要把使用schemas mode 导出的数据,重新导入到另外一个模式中,这时候我们

可以使用remap_schema 参数,为了能够使用remap_schema 方式导入数据,用户应该

事先获得datapump_imp_full_database 角色。下面指定数据的导入。

C:\Users\hello>impdp hr/hr schemas=hr remap_schema=hr:test dumpfile=dmp_dir:hr_schema.dmp logfile=dmp_dir:remap_schema.log

Import: Release 11.2.0.1.0 – Production on Sun Jun 24 09:50:43 2012

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 – Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

Master table “HR”.”SYS_IMPORT_SCHEMA_01″ successfully loaded/unloaded

Starting “HR”.”SYS_IMPORT_SCHEMA_01″:  hr/ schemas=hr remap_schema=hr:test dumpfile=dmp_dir:hr_schema.dmp logfile=dmp_dir:remap_schema.log

Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA

Processing object type SCHEMA_EXPORT/SEQUENCE/SEQUENCE

Processing object type SCHEMA_EXPORT/TABLE/TABLE

Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA

. . imported “TEST”.”COUNTRIES”                          6.367 KB      25 rows

. . imported “TEST”.”DEPARTMENTS”                        7.007 KB      27 rows

. . imported “TEST”.”EMPLOYEES”                          16.80 KB     107 rows

. . imported “TEST”.”JOBS”                               6.984 KB      19 rows

. . imported “TEST”.”JOB_HISTORY”                        7.054 KB      10 rows

. . imported “TEST”.”LOCATIONS”                          8.273 KB      23 rows

. . imported “TEST”.”REGIONS”                            5.476 KB       4 rows

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/VIEW/VIEW

Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT

Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS

Job “HR”.”SYS_IMPORT_SCHEMA_01″ successfully completed at 09:50:53

导入成功以后确定,test 模式中的数据。表中的数据,约束,索引等都是存在的。

SQL> select count(*) from employees;

COUNT(*)

———-

107

SQL> drop table employees;

drop table employees

*

ERROR at line 1:

ORA-02449: unique/primary keys in table referenced by foreign keys

SQL> select index_name from user_indexes

2  where table_name = ‘EMPLOYEES’;

INDEX_NAME

————————————————————

EMP_EMP_ID_PK

EMP_EMAIL_UK

remap_tablespace 方式

在hr 模式中创建emp 表。

SQL> create table emp tablespace users as select * from employees;

Table created.

将emp 表导出。

C:\Users\hello>expdp hr/hr tables=emp dumpfile=dmp_dir:emp_table.dmp nologfile=yes

创建 一个新的用户并赋予相应的权限,注意这里的默认永久表空间是test而不是users.

SQL> create user testing

2  identified by testing

3  default tablespace test

4  temporary tablespace temp;

User created.

SQL> alter user testing default tablespace test quota 20m on test;

User altered.

SQL> grant connect to testing;

Grant succeeded.

SQL> grant create table to testing;

Grant succeeded.

执行导入发现如下的错误。因为用户没有users 表空间的使用权,更不用说配额了。

C:\Users\hello>impdp hr/hr tables=emp remap_schema=hr:testing dumpfile=dmp_dir:emp_table.dmp nologfile=yes

ORA-39083: Object type TABLE:”TESTING”.”EMP” failed to create with error:

ORA-01950: no privileges on tablespace ‘USERS’

下面我们使用remap_tablespace 的方式来处理。将dumpfile 中对users 表空间的引用remap 到test 表空间。

C:\Users\hello>impdp hr/hr tables=emp remap_schema=hr:testing remap_tablespace=users:test dumpfile=dmp_dir:emp_table.dmp nologfile=yes

Import: Release 11.2.0.1.0 – Production on Sun Jun 24 10:59:25 2012

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 – Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

Master table “HR”.”SYS_IMPORT_TABLE_01″ successfully loaded/unloaded

Starting “HR”.”SYS_IMPORT_TABLE_01″:  hr/ tables=emp remap_schema=hr:testing remap_tablespace=users:test dumpfile=dmp_dir:emp_table.dmp nologfile=yes

Processing object type TABLE_EXPORT/TABLE/TABLE

Processing object type TABLE_EXPORT/TABLE/TABLE_DATA

. . imported “TESTING”.”EMP”                             16.79 KB     107 rows

Job “HR”.”SYS_IMPORT_TABLE_01″ successfully completed at 10:59:28

成功的导入了,确定一下testing模式中的数据。

SQL> select count(*) from emp;

COUNT(*)

———-

107

除了上述演示的remap 方式以外还有一个remap_datafile,用来将dumpfile 中包含的数据文件路径,remap 到新的数据数据路径。该参数只有当使用full 模式导入的时候才可以使用。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/212612.html原文链接:https://javaforall.net

(0)
上一篇 2026年3月18日 下午7:40
下一篇 2026年3月18日 下午7:40


相关推荐

  • 一文读懂堆与栈的区别

    一文读懂堆与栈的区别堆(Heap)与栈(Stack)是开发人员必须面对的两个概念,在理解这两个概念时,需要放到具体的场景下,因为不同场景下,堆与栈代表不同的含义。一般情况下,有两层含义:(1)程序内存布局场景下,堆与栈表示的是两种程序内存分区;(2)数据结构场景下,堆与栈表示两种常用的数据结构。1.程序内存分区——堆与栈栈由操作系统自动分配释放,用于存放函数的参数值、局部变量的值等,其操作方式类…

    2022年5月20日
    36
  • web服务器有哪些?_服务器和web服务器有什么区别

    web服务器有哪些?_服务器和web服务器有什么区别<1>什么是web服务器"网络服务"(WebService)的本质,就是通过网络调用其他网站的资源。WebService架构和云如果一个软件的主要部分采用了"网络服务",即它把存储或计算环节"外包"给其他网站了,那么我们就说这个软件属于WebService架构。WebService架构的基本思想,就是尽量把非核心功能交给其他人去做,自己全力开发核心功能。比如,如…

    2026年1月25日
    4
  • vue纯前端分页_基于vue的表格组件

    vue纯前端分页_基于vue的表格组件vue分页组件(比上一版本好看一些),贴代码vue-page.js代码如下varvuePage={ template:’<divclass="page-bar"id="pager">\ <spanclass="form-inline">\ <selectclass="form-control"v-model=&a

    2026年4月20日
    4
  • 技巧 | json中文字符串中文乱码问题[通俗易懂]

    技巧 | json中文字符串中文乱码问题

    2022年2月13日
    46
  • robotium android,android自动化测试框架robotium配置和使用

    robotium android,android自动化测试框架robotium配置和使用背景介绍android开发过程中,每次迭代升级都需要去回归一下之前版本功能,看看最新的修改有没有影响到之前的正常功能。然而这个过程永远都是在做一些繁琐的重复的操作,大大浪费人力,所以我们决定使用自动化来做这个事情,这就引入了我们接下来要介绍的自动化测试框架——robotium。Robotium是一款国外的Android自动化测试框架,主要针对Android平台的应用进行黑盒自动化测试,它提供了模拟…

    2022年7月17日
    15
  • Rust源码分析:channel内部mpsc队列

    Rust源码分析:channel内部mpsc队列

    2026年3月14日
    3

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号