准备工作
需要dmp文件、表空间名、用户名及密码
还原步骤
1.创建数据泵虚拟目录名及指定实际目录
DATA_TMP_DIR为虚拟目录名,d盘为实际目录,都可调整
create or replace directory DATA_TMP_DIR as 'd:\';
2.创建表空间
CREATE TABLESPACE ts_xxx
DATAFILE 'E:\app\xxx\oradata\orcl\xxx.DBF'
size 32000M
AUTOEXTEND ON
NEXT 200M MAXSIZE UNLIMITED
EXTENT MANAGEMENT LOCAL;
3.创建临时表空间
create temporary tablespace ts_xxx_temp
tempfile 'E:\app\xxx\oradata\orcl\xxx_temp.DBF'
size 250m
autoextend on
next 50m maxsize unlimited extent management local;
4.创建用户
create user user_xxx
identified by xxx
default tablespace ts_xxx
temporary tablespace ts_xxx_temp;
5.给用户赋权
grant dba,connect, resource to user_xxx;
grant read,write on directory DATA_TMP_DIR to user_xxx;
6.执行impdp命令
impdp xxx/user_xxx@xxx.xxx.xxx.xxx:1521/orcl DIRECTORY=DATA_TMP_DIR DUMPFILE=xxx.dmp full=y
如果两个库的表空间不对应可以在impdp中加如下:
REMAP_SCHEMA=导出库的表空间:要还原库的表空间 remap_tablespace=导出库的表空间:要还原库的表空间
注意事项:
用数据泵不可以从高版本还原到低版本,除非高版本通过数据泵导出库时指定了数据库版本。
expdp导出的时候 增加一个参数就可以了
参数一般的类型是version = 11.2.0.1.0样式就可以