---
title: "oracle 使用expdp、impdp 备份和恢复数据"
author: "xiaojiit"
date: "2012-12-09T18:02:47Z"
tags: []
categories: ["数据库"]
slug: "oracle-expdp-impdp"
draft: false
lastmod: "2016-11-26T09:38:51Z"
id: 1744570
url: "https://sharejava.iteye.com/blog/1744570"
---

1、还原经常使用exp、imp 备份和还原数据,但这样对 表空间有要求，即：导出前使用的什么表空间，导入时，必须采用相同的表空间，不利于不同数据库之间的备份和恢复。使用expdp、impdp则可以避免此问题

 

2、expdb、impdb使用“目录”，需要先创建目录。

3、创建目录 ：

     用system用户登陆，

     create or replace directory exp\_dir as 'D:/tmp';

       grant read,write on directory exp\_dir to scott;

 

4、进入oracle的BIN目录

    备份： expdp.exe scott/123456 schemas=scott directory=exp\_dir dumpfile=scott.dmp logfile=expscott.log 

    备份完成之后，scott.dmp和expscott.log将存放在D:/tmp文件夹中

 

    恢复：先把由expdb备份出来的文件，放入D:/tmp中

                然后进 impdp.exe scott/123456 schemas=scott directory=exp\_dir dumpfile=scott.dmp

 

5、删除目录：

      drop directory exp\_dir;

 

 

6、如果两端的数据库版本不一至，可在导入导出命令加 version=10.2.0.1.0 ，指定导出的版本。

      如： expdp.exe scott/123456 schemas=scott directory=exp\_dir dumpfile=scott.dmp logfile=expscott.log version=10.2.0.1.0

                impdp.exe scott/123456 schemas=scott directory=exp\_dir dumpfile=scott.dmp version=10.2.0.1.0