oracle数据库导出导入

1.通过dos命令
运行(win+r) -> 输入cmd,回车 -> 输入exp tom/tom@192.168.1.186:1521/orcl file=d:/daochu.dmp,第一个tom是数据库用户名,第二个tom是数据库密码,ip地址是数据库所在电脑的ip地址,orcl是sid的名字,d:/daochu.dmp表示导出文件的目录及名称。在本地数据库创建用户,授予权限,赋予角色:
--创建用户
create user tom
identified by tom
account unlock;

--授予权限
grant create session to tom;
grant create table to tom;

--赋予角色
grant dba to tom;

导入:
imp tom/tom@localhost:1521/mydb file=d:/daochu.dmp from user=tom to user=tom

级联删除用户tom:
drop user tom cascade;

参考博客:http://blog.csdn.net/u010999809/article/details/75331006

单表备份(前提库的结构是一样的)
导出:
开始钮->运行->输入CMD->进入DOS界面
EXP 用户名/密码@连接字符串 GRANTS=Y TABLES=(stu) file=C:文件名.DMP
导入:
开始钮->运行->输入CMD->进入DOS界面
IMP 用户名/密码@连接字符串 IGNORE=Y TABLES=(stu) FULL=N file=C:文件名.DMP
其中stu是你要的表名

全库导
导出:
开始钮->运行->输入CMD->进入DOS界面
EXP 用户名/密码@连接字符串 FULL=Y file=C:文件名.DMP
导入:
开始钮->运行->输入CMD->进入DOS界面
IMP 用户名/密码@连接字符串 FULL=Y file=C:文件名.DMP

使用实例(oracle 9i)
--创建用户并授权
create user 用户名 identified by 密码;
grant connect,resource,dba to 用户名;
--按用户导出
exp 用户名/密码@数据库名称 owner=用户名 file=绝对路径(D:\test.dmp)
--按用户导入
imp 用户名/密码@数据库名称 file=绝对路径(D:\test.dmp) full=y;

参考博客:https://www.2cto.com/database/201409/338485.html

2.通过plsql
导出步骤 tools ->export user object 选择选项,导出.sql文件 说明:导出的是建表语句(包括存储结构)
 tools ->export tables-> Oracle Export 选择选项导出.dmp文件 说明:包含三种导出方式,三种方式都能导出表结构以及数据.
第一种是导出为.dmp的文件格式,.dmp文件是二进制的,可以跨平台,还能包含权限,效率也很不错,用得最为广泛 。
第二种是导出为.sql文件的,可用文本编辑器查看,通用性比较好,但效率不如第一种,适合小数据量导入导出。尤其注意的是表中不能有大字段(blob,clob,long),如果有,会提示不能导出(提示如下: table contains one or more LONG columns cannot export in sql format,user Pl/sql developer format instead)。
第三种是导出为.pde格式的,.pde为Pl/sql developer自有的文件格式,只能用Pl/sql developer自己导入导出,不能用编辑器查看。
导入步骤:a.tools->import tables->SQL Inserts 导入.sql文件。b. tools->import talbes->Oracle Import然后再导入dmp文件。 说明:和导出类似,另外,导入之前最好把以前的表删除,当然导入另外数据库除外。
在本地数据库创建用户,授予权限,赋予角色:
--创建用户
create user tom
identified by tom
account unlock;

--授予权限
grant create session to tom;
grant create table to tom;

--赋予角色
grant dba to tom;

导入:
imp tom/tom@localhost:1521/mydb file=d:/daochu.dmp from user=tom to user=tom

级联删除用户tom:
drop user tom cascade;

参考博客:https://jingyan.baidu.com/article/d5a880eb69ff7313f047cc5f.html

原文地址:https://www.cnblogs.com/cyf18/p/14285257.html