oracle还原dmp数据库
1.CMD登录sqlplus
sqlplus system/123456@orcl as sysdba
2通过sql,查询数据库表空间存放位置;
select file_name from dba_data_files;
3.创建数据库临时表空间;(注意空格符)
create temporary tablespace abctmp
tempfile 'E:\APP\ADMINISTRATOR\ORADATA\ORCL\file_abctmp.dbf'
size 50m
autoextend on next 50m maxsize 2048m extent management local;
4.创建数据表空间; (注意空格符)
create tablespace abc
datafile 'E:\APP\ADMINISTRATOR\ORADATA\ORCL\data_abc.dbf'
size 50m
autoextend on next 50m maxsize 2048m
extent management local;
5.创建用户名指定表空间和临时表空间;
create user abc identified by abc default tablespace abc
temporary tablespace abctmp;
6.为用户分配权限;
grant connect,resource,dba to abc;
7.导入数据库(cmd执行)第一种
imp abc/abc@orcl file=C:\example.dmp full=y ignore=y
如果错误,试试第二种:
Import: Release 11.2.0.1.0 - Production on 星期一 1月 14 11:05:57 2019
Copyright © 1982, 2009, Oracle and/or its affiliates. All rights reserved.
连接到: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Produc
tion
With the Partitioning, OLAP, Data Mining and Real Application Testing options
IMP-00038: 无法转换为环境字符集句柄
IMP-00000: 未成功终止导入
第二种:使用impdp导入,只能导入expdp导出的dmp文件
1.登录Sql plus
2.创建DIRECTORY(目录下存放要导入的dmp文件
create or replace directory ABCDIR as 'c:\';
3.把目录给用户授权,自己不能给自己授权,通过sql,查询创建的的directory[select directory_path from all_directories;] 或[select * from dba_directories;]对照物理目录是否存在问题
grant read,write on directory ABCDIR to system;
4.用system用户导入,这样就会按照expdp导出的用户名,密码和表空间会自动创建相同名称的用户名导入成功
impdp 'system/123456@orcl as sysdba' directory=ABCDIR
dumpfile='example.dmp' logfile=example.log full=y
5.如果需要更改用户 表空间
impdp system/123456@orcl
directory=ABCDIR
dumpfile=example.dmp
remap_schema=olduser:newuser
remap_tablespace=oldtablespace:newtablespace,oldtablespacetmp:newtablespacetemp
以imp或impdp开头的在CMD命令里执行,其余是sql在Sql Plus里面执行。