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=yExport: Release 11.2.0.1.0 - Productionon Tue Apr 23 20:24:44 2013Copyright (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.dmpImport: Release 11.2.0.1.0 - Productionon Tue Apr 23 20:27:30 2013Copyright (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 SYSOPERUsername: 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=scottImport:Release 11.2.0.1.0 - Production on Tue Apr 23 20:31:37 2013Copyright (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 SYSOPERUsername: 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. RMAN快速入门指南

    RMAN快速入门指南   1. What is RMAN? 什么是RMAN?    4 2. Terminology 专业词汇解释    4 2.1. Backup sets 备份集合    4 2. ...

  2. Shiro第一个程序:官方快速入门程序Qucickstart详解教程

    目录 一.下载解压 二.第一个Shiro程序 1. 导入依赖 2. 配置shiro配置文件 3. Quickstart.java 4. 启动测试 三.shiro.ini分析 四.Quickstart. ...

  3. 计算机入门新人必学,异世修真人怎么玩?新手快速入门必备技巧

    异世修真人怎么快速入门?最近新出来的一款文字修仙游戏,很多萌新不知道怎么玩?进小编给大家带来了游戏新手快速入门技巧攻略,希望可以帮到大家. 新手快速入门攻略 1.开局出来往下找婆婆,交互给点钱,旁边有 ...

  4. Spring Boot 2 快速教程:WebFlux 快速入门(二)

    2019独角兽企业重金招聘Python工程师标准>>> 摘要: 原创出处 https://www.bysocket.com 「公众号:泥瓦匠BYSocket 」欢迎关注和转载,保留摘 ...

  5. Apache Hive 快速入门 (CentOS 7.3 + Hadoop-2.8 + Hive-2.1.1)

    2019独角兽企业重金招聘Python工程师标准>>> 本文节选自<Netkiller Database 手札> 第 63 章 Apache Hive 目录 63.1. ...

  6. 《iOS9开发快速入门》——导读

    本节书摘来自异步社区<iOS9开发快速入门>一书中的目录,作者 刘丽霞 , 邱晓华,更多章节内容可以访问云栖社区"异步社区"公众号查看 目 录 前 言 第1章 iOS ...

  7. BIML 101 - ETL数据清洗 系列 - BIML 快速入门教程 - 序

    BIML 101 - BIML 快速入门教程 做大数据的项目,最花时间的就是数据清洗. 没有一个相对可靠的数据,数据分析就是无木之舟,无水之源. 如果你已经进了ETL这个坑,而且预算有限,并且有大量的 ...

  8. python scrapy菜鸟教程_scrapy学习笔记(一)快速入门

    安装Scrapy Scrapy是一个高级的Python爬虫框架,它不仅包含了爬虫的特性,还可以方便的将爬虫数据保存到csv.json等文件中. 首先我们安装Scrapy. pip install sc ...

  9. OpenStack快速入门

    OpenStack云计算快速入门(1) 该教程基于Ubuntu12.04版,它将帮助读者建立起一份OpenStack最小化安装.我是五岳之巅,翻译中多采用意译法,所以个别词与原版有出入,请大家谅解.我 ...

  10. Expression Blend实例中文教程(2) - 界面快速入门

    上一篇主要介绍Expression系列产品,另外概述了Blend的强大功能,本篇将用Blend 3创建一个新Silverlight项目,通过创建的过程,对Blend进行快速入门学习. 在开始使用Ble ...

最新文章

  1. mysql执行计划extra为null_MySQL执行计划extra解析
  2. java jsp filename filepath 图片上传_SpringMVC实现文件上传与下载
  3. python模拟火车订票系统_如何用python编写火车抢票助手
  4. modbus报文解析实例_云原生、全栈可编程的下一代SDN解析与实践 (一)丨传统SDN架构演进...
  5. graphpad7.04多组比较p值_同是折线图为何你却这么优秀,这才是多组数据作图应该有的样子...
  6. [html] 使用svg画一个微信的logo
  7. ACMMM2021|在多模态训练中融入“知识+图谱”:方法及电商应用实践
  8. python动物代码大全_python爬虫代码大全
  9. 转 Hystrix超时实现机制
  10. 简述JDBC原理 + 在JAVA中异常是什么 + throws 与 throw 区别 + 简单解释以下JAVA中的多态...
  11. 面试怪事:网上抄答案的程序员
  12. MySQL的启动和停止
  13. 【计算机网络】数据通信的基础知识
  14. PMP专题练习-整合管理
  15. 技术支持程序员程序书写规范
  16. Linux软件集成开发环境
  17. linux中scsi驱动程序,不用软驱 在Linux上也能安装RAID驱动程序
  18. Linux(十二)中断系统
  19. 社交电商:拼团与分销商业模式的区别在哪里?
  20. php一条SQL语句mysql插入两条重复的数据

热门文章

  1. 【GIF动画+完整可运行源代码】C++实现 冒泡排序——十大经典排序算法之一
  2. ae saber插件_入门AE:影视特效中的黑洞是怎么做的?附带教程
  3. mysql表操作_MySQL表操作语句用法百科
  4. PHP读取TXT UTF-8,2)PHP中把读取.txt中内容并转为UTF-8格式
  5. linux笔记之 rpm常用参数 ,yum安装编译器,httpd服务的开关
  6. linux 添加用户_linux ---添加普通用户账号
  7. qt百度地图html,Qt的QWebChannel和JS、HTML通信/交互驱动百度地图
  8. 计算机英语句子缩略,根据汉语意思完成英语句子,每空一词(含缩略形式)。 【1】-咋考网...
  9. bootstrap的td可以增加title样式_3.CSS样式的三种使用方式
  10. android singleinstance home,Android启动模式之singleinstance的坑