oracle数据库的备份与恢复(expdp与impdp)

本文档详细介绍了Oracle11g环境下如何利用数据泵功能进行数据的导出与导入操作,包括环境配置、创建外部目录、不同模式的数据导出与导入等,并提供了具体的SQL语句示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

oracle 11g 初学者指南

http://www.cnblogs.com/netsql/articles/1745978.html

网上的资料都很零碎,而且大部分都不能完成要求的功能,所以做了些整理与完善

准备工作
 1 在环境变量中队bin目录进行配置。默认情况下,安装oracle数据库时,将自动配置相应的环境变量,
     例如D:/oracle/product/10.2.0/db_1/BIN
   2 在oracle安装路径的bin文件夹中,确定expdp.exe和impdp.exe文件的存在。
   3 创建一个外部目录。
     data pump要求为将要创建和读取的数据文件和日志文件创建目录,用来指向
     使用的外部目录。在oracle中创建目录对象时,可以使用 create directory
     语句。
   【实例】
     1,检查,高级环境变量-pathpath里面有无bin目录
     2,检查expdp.exe、impdp.exe文件是否存在。
     3,建立目录

  1. c:/> sqlplus /nolog  
  2. sql> conn sys/sys as sysdba  
  3. sql> create directory mypump as 'd:/app/temp';  
  4. sql> grant read, write on directory mypump to scot  

实现数据导出

【实例】
     1,表模式导出
       expdp scott/scott_2009 directory=mypumpdumpfile=expdptab.dmp tables=dept,emp
       (select * from dba_tablespaces; altertablespace testspace online;)

     2,schema模式导出

     (ORA-39083 这个错误的原因是出在用户的权限上,而且是在导出的时候在expdp之前执行  grant EXP_FULL_DATABASE to scott;)
        expdp system/system directory=mypumpdumpfile=expdp.dmp schemas=scott nologfile=y
     3,表空间数据导出
       expdp system/system directory=mypumpdumpfile=expdpspace.dmp tablespaces=EPISCMCC_DTS

     4,全库模式导出
       expdpsystem/system directory=mypump dumpfile=expdp.dmp full=y

实现数据导入

  1,表模式导入
        impdpscott/scott_2009 directory=mypump dumpfile=expdptab.dmp tables=dept,emp 

   2,schema模式导入
       impdpsystem/system directory=mypump dumpfile=expdp.dmp schemas=scott 

   3,表空间数据导入
       impdp system/tiger directory=mypump dumpfile=expdspaces.dmp remap_tablespace=EPISCMCC_DTS:EPISCMCC_DTS table_exists_action=replace

   4,全库模式导入
       impdpsystem/system directory=mypump dumpfile=expdp.dmp full=y table_exists_action=replace


其中:在表空间导入与全库导入的时候要事先创建表空间与相应的表空间下的用户具体步骤如下:


导入到数据库之前,要在新数据库创建相应的表空间及用户
其中源数据库中的表空间为EPICMCC_DTS,该表空间下的用户为EPICMCC


  1. /*创建临时表空间*/  
  2. create temporary tablespace EPISCMCC_TEMP  
  3. tempfile 'C:\app\z002w00r-e01\oradata\orcl\EPISCMCC_TEMP.dbf'  
  4. size 50m  
  5. autoextend on  
  6. next 50m maxsize 20480m  
  7. extent management local  
  8.   
  9. /*创建表空间*/  
  10. create tablespace EPISCMCC_DTS  
  11. logging  
  12. datafile 'C:\app\z002w00r-e01\oradata\orcl\EPISCMCC_DTS.dbf'  
  13. size 50m  
  14. autoextend on  
  15. next 50m maxsize 20480m  
  16. extent management local  
  17.   
  18. /*创建用户指定表空间*/  
  19. create user EPISCMCC identified by tiger  
  20. default tablespace EPISCMCC_DTS  
  21. temporary tablespace EPISCMCC_TEMP  
  22.   
  23. /*给用户授权*/  
  24. grant connect,resource,dba to EPISCMCC 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值