1、数据导出基础

(1)创建datapump导出文件的目录对象并为相应用户授予权限。

出于安全考虑,不允许oracle用户直接在OS上进行文件的操作,而应通过directory对象指定。

SQL> create directory dpump_dir1 AS '/opt/oracle/admin/orcl11g/dpdump';
Directory created.
SQL> grant read, write on directorydpump_dir1 to scott;
Grant succeeded.

(2)导出

[oracle@lujinhong dpdump]$ expdpscott/tiger directory=DPUMP_DIR1 dumpfile=scott.dmp nologfile=y

Export: Release 11.2.0.1.0 - Productionon Tue Apr 23 20:24:44 2013

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

Connected to: Oracle Database 11gEnterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Miningand Real Application Testing options
Starting"SCOTT"."SYS_EXPORT_SCHEMA_01": scott/******** directory=DPUMP_DIR1dumpfile=scott.dmp nologfile=y
Estimate in progress using BLOCKSmethod...
Processing object typeSCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method:192 KB
Processing object typeSCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object typeSCHEMA_EXPORT/TABLE/TABLE
Processing object typeSCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object typeSCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object typeSCHEMA_EXPORT/TABLE/COMMENT
Processing object typeSCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
Processing object typeSCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . exported"SCOTT"."DEPT" 5.937 KB 4 rows
. . exported"SCOTT"."EMP" 8.570 KB 14 rows
. . exported"SCOTT"."SALGRADE" 5.867 KB 5 rows
. . exported"SCOTT"."BONUS" 0 KB 0 rows
Master table"SCOTT"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set forSCOTT.SYS_EXPORT_SCHEMA_01 is:
/opt/oracle/admin/orcl11g/dpdump/scott.dmp
Job"SCOTT"."SYS_EXPORT_SCHEMA_01" successfully completed at20:25:08

注意:directory=DPUMP_DIR1中的DPUMP_DIR1应该在dba_directories中存在,否则应该在第一步中先创建然后授权。

2、数据导入基础

若即将导入的用户或者表空间不存在,则必须先创建用户及表空间。

[oracle@lujinhong dpdump]$ impdp sys/Lu123456 directory=dpump_dir1dumpfile=scott.dmp

Import: Release 11.2.0.1.0 - Productionon Tue Apr 23 20:27:30 2013

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

UDI-28009: operation generated ORACLEerror 28009
ORA-28009: connection as SYS should beas SYSDBA or SYSOPER Username: sys as sysdba
Password: Connected to: Oracle Database 11gEnterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Miningand Real Application Testing options
Master table"SYS"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting"SYS"."SYS_IMPORT_FULL_01": sys/******** AS SYSDBA directory=dpump_dir1 dumpfile=scott.dmp
Processing object typeSCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object typeSCHEMA_EXPORT/TABLE/TABLE
ORA-39151: Table"SCOTT"."DEPT" exists. All dependent metadata and data willbe skipped due to table_exists_action of skip
ORA-39151: Table "SCOTT"."EMP"exists. All dependent metadata and data will be skipped due totable_exists_action of skip
ORA-39151: Table"SCOTT"."BONUS" exists. All dependent metadata and datawill be skipped due to table_exists_action of skip
ORA-39151: Table"SCOTT"."SALGRADE" exists. All dependent metadata and datawill be skipped due to table_exists_action of skip
Processing object typeSCHEMA_EXPORT/TABLE/TABLE_DATA
Processing object typeSCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object typeSCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object typeSCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object typeSCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
Processing object typeSCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Job "SYS"."SYS_IMPORT_FULL_01"completed with 4 error(s) at 20:27:41
由于原来已经存在这些表,因此先删除再导入:
SQL> drop table emp; Table dropped. SQL> select * from emp;
select * from emp
*
ERROR at line 1:
ORA-00942: table or view does not exist [oracle@lujinhongdpdump]$ impdp sys/Lu123456 directory=dpump_dir1 dumpfile=scott.dmpschemas=scott Import:Release 11.2.0.1.0 - Production on Tue Apr 23 20:31:37 2013 Copyright (c)1982, 2009, Oracle and/or its affiliates. All rights reserved. UDI-28009:operation generated ORACLE error 28009
ORA-28009:connection as SYS should be as SYSDBA or SYSOPER Username: sysas sysdba
Password: Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With thePartitioning, OLAP, Data Mining and Real Application Testing options
Master table"SYS"."SYS_IMPORT_SCHEMA_01" successfully loaded/unloaded
Starting"SYS"."SYS_IMPORT_SCHEMA_01": sys/******** AS SYSDBA directory=dpump_dir1dumpfile=scott.dmp schemas=scott
Processingobject type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processingobject type SCHEMA_EXPORT/TABLE/TABLE
ORA-39151:Table "SCOTT"."DEPT" exists. All dependent metadata anddata will be skipped due to table_exists_action of skip
ORA-39151:Table "SCOTT"."BONUS" exists. All dependent metadata anddata will be skipped due to table_exists_action of skip
ORA-39151:Table "SCOTT"."SALGRADE" exists. All dependent metadata anddata will be skipped due to table_exists_action of skip
Processingobject type SCHEMA_EXPORT/TABLE/TABLE_DATA
. .imported "SCOTT"."EMP" 8.570 KB 14 rows
Processingobject type SCHEMA_EXPORT/TABLE/INDEX/INDEX
Processingobject type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processingobject type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processingobject type SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
Processingobject type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Job"SYS"."SYS_IMPORT_SCHEMA_01" completed with 3 error(s) at20:31:44

3、导出、导入参数

不管是expdp还是impdp均存在大量的参数,以对导入导出过程进行灵活的配置,详见《数据库管理艺术》第14章。

(1)重映射参数【导入参数】

一般情况下,不管使用哪个用户进行导入,导入的数据均归属到数据原有的用户名下。如使用sys用户进行导入操作,但数据是从scott导出的,则数据将被导入至scott模式下。除非使用remap_schema参数。

[oracle@datatest_db1_160 irms_gd]$ impdpsystem/Lu123456 directory=dpump_dir dumpfile=scott.dmp remap_schema=scott:test_datapump

类似的参数还有remap_table,remap_tablespace,remap_datafile, remap_data。

4、实例

从项目中把表名中包含BTS的表导出,然后导入至测试库中。

(1)导出

SQL>select * from dba_directories;
bash-4.1$ expdpHN_CM_IRMS_35/HN_CM_IRMS_351 directory=EXPDIR DUMPFILE=HN.DMPinclude=TABLE\:\"LIKE \'%BTS%\'\"

(2)导入

[oracle@lujinhong /]$ impdp HN_CM_IRMS_35/HN_CM_IRMS_351directory=dpump_dir1 dumpfile=HN1.DMP

5、项目导出语句

#!/bin/bash
export ORACLE_BASE=/opt/ORACLE
export ORACLE_SID=IRMS
exportORACLE_HOME=/opt/ORACLE/irms/product/10.2.0/db_1
exportPATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:$HOME/bin:/usr/bin/X11:/sbin:
export PATH=$ORACLE_HOME/bin:$PATH
user='system'
passwd='Ora_8109#'
datestr=`date +"%Y%m%d"`
expdp ${user}/${passwd}directory=expdp_bak dumpfile=XZ_CM_IRMS_35_${datestr}.dmp logfile=XZ_CM_IRMS_35_${datestr}.log schemas=XZ_CM_IRMS_35 exclude=statistics

在导入时,可以使用replace参数,这样的话就不需要先手工删除原有数据,再进行导入。

RMAN之一:快速入门的更多相关文章

  1. Web Api 入门实战 (快速入门+工具使用+不依赖IIS)

    平台之大势何人能挡? 带着你的Net飞奔吧!:http://www.cnblogs.com/dunitian/p/4822808.html 屁话我也就不多说了,什么简介的也省了,直接简单概括+demo ...

  2. SignalR快速入门 ~ 仿QQ即时聊天,消息推送,单聊,群聊,多群公聊(基础=》提升)

     SignalR快速入门 ~ 仿QQ即时聊天,消息推送,单聊,群聊,多群公聊(基础=>提升,5个Demo贯彻全篇,感兴趣的玩才是真的学) 官方demo:http://www.asp.net/si ...

  3. 前端开发小白必学技能—非关系数据库又像关系数据库的MongoDB快速入门命令(2)

    今天给大家道个歉,没有及时更新MongoDB快速入门的下篇,最近有点小忙,在此向博友们致歉.下面我将简单地说一下mongdb的一些基本命令以及我们日常开发过程中的一些问题.mongodb可以为我们提供 ...

  4. 【第三篇】ASP.NET MVC快速入门之安全策略(MVC5+EF6)

    目录 [第一篇]ASP.NET MVC快速入门之数据库操作(MVC5+EF6) [第二篇]ASP.NET MVC快速入门之数据注解(MVC5+EF6) [第三篇]ASP.NET MVC快速入门之安全策 ...

  5. 【番外篇】ASP.NET MVC快速入门之免费jQuery控件库(MVC5+EF6)

    目录 [第一篇]ASP.NET MVC快速入门之数据库操作(MVC5+EF6) [第二篇]ASP.NET MVC快速入门之数据注解(MVC5+EF6) [第三篇]ASP.NET MVC快速入门之安全策 ...

  6. Mybatis框架 的快速入门

    MyBatis 简介 什么是 MyBatis? MyBatis 是支持普通 SQL 查询,存储过程和高级映射的优秀持久层框架.MyBatis 消除 了几乎所有的 JDBC 代码和参数的手工设置以及结果 ...

  7. grunt快速入门

    快速入门 Grunt和 Grunt 插件是通过 npm 安装并管理的,npm是 Node.js 的包管理器. Grunt 0.4.x 必须配合Node.js >= 0.8.0版本使用.:奇数版本 ...

  8. 【第一篇】ASP.NET MVC快速入门之数据库操作(MVC5+EF6)

    目录 [第一篇]ASP.NET MVC快速入门之数据库操作(MVC5+EF6) [第二篇]ASP.NET MVC快速入门之数据注解(MVC5+EF6) [第三篇]ASP.NET MVC快速入门之安全策 ...

  9. 【第四篇】ASP.NET MVC快速入门之完整示例(MVC5+EF6)

    目录 [第一篇]ASP.NET MVC快速入门之数据库操作(MVC5+EF6) [第二篇]ASP.NET MVC快速入门之数据注解(MVC5+EF6) [第三篇]ASP.NET MVC快速入门之安全策 ...

  10. Vue.js 快速入门

    什么是Vue.js vue是法语中视图的意思,Vue.js是一个轻巧.高性能.可组件化的MVVM库,同时拥有非常容易上手的API.作者是尤雨溪,写下这篇文章时vue.js版本为1.0.7 准备 我推荐 ...

随机推荐

  1. 在VS中如何用C++连接Mysql

    在如鹏网上看到的如何用C连接Mysql,解决了大二时的一直困惑,大喜! 第一步下载 安装的数据库是如鹏网的Mysql :http://pan.baidu.com/s/1c0m3xIw 提取码:m9sn ...

  2. 飘逸的python - 多条件排序及itemgetter的应用

    曾经客户端的同事用as写一大堆代码来排序,在得知python排序往往只需要一行,惊讶无比,遂对python产生浓厚的兴趣. 之前在做足球的积分榜的时候需要用到多条件排序,如果积分相同,则按净胜球,再相 ...

  3. 关于mysql中数据存储复合树形结构,查询时结果按树形结构输出

    1.主要思想:根据已有数据,规则性的造数据 select * FROM(select lId,strName,lId as lParentId,-1 as orderIdx from tbClassi ...

  4. Hadoop2.4.1入门实例:MaxTemperature

    注意:以下内容在2.x版本与1.x版本同样适用,已在2.4.1与1.2.0进行测试. 一.前期准备 1.创建伪分布Hadoop环境,请参考官方文档.或者http://blog.csdn.net/jed ...

  5. javaScript中小数取整,四种方法的比较

    1.parseInt:只取整数位例如:parseInt(3.7) 取整结果为:3parseInt(-1.1) 取整结果为:-1 2.Math.floor :向下去整,取大的整数例如:Math.floo ...

  6. Qt中调用PolarSSL库(一)

    最近一直在学习SSL相关的知识,也是先了解理论相关的知识,主要是SSL相关的基本概念和连接建立过程,主要是基于PolarSSL开源库进行学习.学习完了之后就希望能给有所运用,就想用Qt写一个简单的程序 ...

  7. WPF笔记(1.2 Navigation导航)——Hello,WPF!

    原文:WPF笔记(1.2 Navigation导航)--Hello,WPF! 这一节是讲导航的.看了一遍,发现多不能实现,因为版本更新了,所以很多旧的语法不支持了,比如说,不再有NavigationA ...

  8. httrack,webdup,WinHTTrack,WebZip

    怎么下载摄像头游戏jabbo,并使其能离线运行?修改 1.摄像头游戏jabbo:JABBO Ultimatum by LiveMurals Interactive电脑为:windows 7 32位.试 ...

  9. DDMS files not found:hprof-conv.exe的解决办法

    或者是you must restart adb and eclipse这类错误 原因:一般是豌豆荚之类的软件影响的,所以,以后要慎用了. 解决方案:先找一下在sdk\tools目录下是否有hprof- ...

  10. VS2008远程调试

    环境:      同一局域网内,主机和虚拟机远程调试   远程计算机:虚拟机搭的WindowsXP/32(局域网中使用桥接,非局域网使用NAT)     本地计算机:Windows XP.Win71. ...