创建用户

创建三个用户test1,test2,test3及表table1,table2,table3

SQL> create user test1 identified by test1 default tablespace users;

User created.

SQL> grant connect,resource to test1;

Grant succeeded.

SQL> create table test1.table1 as select * from dba_objects;

Table created.

SQL> select count(1) from test1.table1;

  COUNT(1)
----------
87459
create user test2 identified by test2 default tablespace users;
grant connect,resource to test2;
create table test2.table2 as select * from dba_objects; create user test3 identified by test3 default tablespace users;
grant connect,resource to test3;
create table test3.table3 as select * from dba_objects;

导出数据

$ exp system/oracle file=test.dmp owner=test1,test2,test3

...

About to export specified users ...
. exporting pre-schema procedural objects and actions
. exporting foreign function library names for user TEST1
. exporting foreign function library names for user TEST2
. exporting foreign function library names for user TEST3

...

Export terminated successfully without warnings.

清理数据

drop table test1.table1 purge;
drop table test2.table2 purge;
drop table test3.table3 purge;

导入数据

1.乱序导入

$ imp system/oracle fromuser=test1,test2,test3 touser=test3,test1,test2 file=test.dmp
...
. importing TEST1's objects into TEST3
. importing TEST2's objects into TEST1
. importing TEST3's objects into TEST2
...
Import terminated successfully without warnings.
$ sqlplus / as sysdba
SQL> select count(1) from test1.table2; COUNT(1)
----------
87461 SQL> select count(1) from test2.table3; COUNT(1)
----------
87461 SQL> select count(1) from test3.table1; COUNT(1)
----------
87461

总结:导入的时候不会主动识别用户名进行匹配,而是根据fromuser和touser的排列按顺序匹配进行导入。

2.fromuser<touser

清理数据:
drop table test1.table2 purge;
drop table test2.table3 purge;
drop table test3.table1 purge;
导入:
$ imp system/oracle fromuser=test1,test2 touser=test1,test2,test3 file=test.dmp
...
. importing TEST1's objects into TEST1
. importing TEST2's objects into TEST2
...
Import terminated successfully without warnings.
验证:
SQL> select owner,table_name from dba_tables where owner in ('TEST1','TEST2','TEST3'); OWNER TABLE_NAME
---------- ------------------------------
TEST2 TABLE2
TEST1 TABLE1

总结:当fromuser<touser时,仍然按顺序匹配将fromuser下的对象导入到touser。多出的touser不作处理,不导入任何数据。

3.fromuser>touser

清理数据:
drop table test1.table1 purge;
drop table test2.table2 purge; 导入:
$ imp system/oracle fromuser=test1,test2,test3 touser=test1,test2 file=test.dmp
...
. importing TEST1's objects into TEST1
. importing TEST2's objects into TEST2
. importing TEST3's objects into TEST3
...
Import terminated successfully without warnings. 验证:
SQL> select owner,table_name from dba_tables where owner in ('TEST1','TEST2','TEST3'); OWNER TABLE_NAME
---------- ------------------------------
TEST1 TABLE1
TEST2 TABLE2
TEST3 TABLE3

总结:fromuser>touser时,多出的用户会在数据库中找到对应相同账户并导入数据。(相同账户在目标数据库中存在的情况下)

当账户在目标库中不存在时,会报错,并忽略掉对该用户的导入:

SQL> drop user test3 cascade;

User dropped.

$ imp system/oracle fromuser=test1,test2,test3  touser=test1,test2 file=test.dmp

...
. importing TEST1's objects into TEST1
. importing TEST2's objects into TEST2
. importing TEST3's objects into TEST3
IMP-00003: ORACLE error 1435 encountered
ORA-01435: user does not exist
....
Import terminated successfully with warnings.

SQL> select owner,table_name from dba_tables where owner in ('TEST1','TEST2','TEST3');


OWNER TABLE_NAME
---------- ------------------------------
TEST1 TABLE1
TEST2 TABLE2

exp/imp 多用户导入导出的更多相关文章

  1. Oracle exp/imp数据导入导出工具基本用法

    一.获取帮助 exp/imp help=y 二.数据导出 1.将数据库完全导出,设置full选项exp system/manager@orcl file=d:\db.dmp full=y 2.导出数据 ...

  2. exp/imp 数据库数据导出/导入

    一.exp数据导出 1.导出全部数据 exp 用户名/密码@服务名 file=文件存储路径/xxx.dmp log=日志存储路径/xxx.log full=y 例: [oracle@dbservice ...

  3. 用exp、dmp导入导出用户到同一个实例下时,类型type会有问题

    oralce的type都有唯一id,在同一个实例下,通过导入导出方法创建type时,会有唯一性问题 最好的解决方法使用impdb,expdb的方式导入导出 用oid=n解决. 实在不行,可用稍微麻烦的 ...

  4. [terry笔记]Oracle数据泵-schema导入导出

    数据泵是10g推出的功能,个人倒数据比较喜欢用数据泵. 其导入的时候利用remap参数很方便转换表空间以及schema,并且可以忽略服务端与客户端字符集问题(exp/imp需要排查字符集). 数据泵也 ...

  5. oracle数据库数据导入导出步骤(入门)

    oracle数据库数据导入导出步骤(入门) 说明: 1.数据库数据导入导出方法有多种,可以通过exp/imp命令导入导出,也可以用第三方工具导出,如:PLSQL 2.如果熟悉命令,建议用exp/imp ...

  6. Oracle数据库导入导出 imp/exp备份还原

    Oracle数据导入导出imp/exp   Oracle数据导入导出imp/exp 在cmd的dos命令提示符下执行,而不是在sqlplus里面,但是格式一定要类似于:   imp/exp 用户名/密 ...

  7. linux 下使用exp/imp 或者expdp/impdp导出导入oracle数据表数据

    一.环境配置 1.执行环境: exp/imp可以在客户端执行也可以在服务器端执行,在客户端执行需要先安装有oracle的客户端,如果是linux系统,就是以oracle用户登录,在控制台下执行.建议在 ...

  8. EXP/IMP 导出生产库表的指定数据到测试库一例

    一般来讲,EXP/IMP是上一代导出导入程序,EXPDP/IMPDP是新一代的导出导入程序.对于大数据量的导出导入首选EXPDP/IMPDP,可以用到并行度,对表空间等操作上也更加的灵活.对于小数据量 ...

  9. Oracle 【IT实验室】数据库备份与恢复之一:exp/imp(导出与导入&装库与卸库)

    1.1  基本命令 1.  获取帮助 $ exp help=y $ imp help=y     2.  三种工作方式 (1)交互式方式 $ exp        //  然后按提示输入所需要的参数 ...

随机推荐

  1. python解析域名

    #coding:utf-8 import socket def URL2IP(): for oneurl in urllist.readlines(): url=str(oneurl.strip()) ...

  2. Redux 核心概念

    http://gaearon.github.io/redux/index.html ,文档在 http://rackt.github.io/redux/index.html .本文不是官方文档的翻译. ...

  3. mysql常用的提权方法

    一,利用MOF提权 Windows 管理规范 (WMI) 提供了以下三种方法编译到 WMI 存储库的托管对象格式 (MOF) 文件: 方法 1: 运行 MOF 文件指定为命令行参数将 Mofcomp. ...

  4. ehcachexml文件解释

    怎么修改默认配置

  5. [国嵌攻略][092][UDP网络程序设计]

    server.c #include <sys/socket.h> #include <netinet/in.h> #include <strings.h> #inc ...

  6. 从零开始学习前端JAVASCRIPT — 2、JavaScript基础ES5

    1:ES5简介 ECMAScript 5.1 (或仅 ES5) 是ECMAScript(基于JavaScript的规范)标准的修正. 与HTML5规范进程本质类似,ES5通过对现有JavaScript ...

  7. EF+MVC学习中的不理解的问题

    1.之所以被定义为virtual便于实现延迟加载 代码: public virtual ICollection<Enrollment> Enrollments { get; set; } ...

  8. SSL证书安装指引

    https://cloud.tencent.com/document/product/400/4143 下载得到的 www.domain.com.zip 文件,解压获得3个文件夹,分别是Apache. ...

  9. 人人都是CEO

    在这个互联网崛起的时代有些流行说法,比如:人人都是产品经理,人人都是程序员以突显行业繁荣的特点,但从更基本的出发点,难道人人不都是 CEO 么?个人的 CEO. 从这个名字套路出发,我沿着想了下去,作 ...

  10. Android带有粘性头部的ScrollView

    前言,一天在点外卖的时候,注意到饿了么列表页的滑动效果不错,但是觉得其中的手势滑动还是挺复杂的,正好又碰到了在熟悉Touch事件的理解当中,所以就抽空对着饿了么的列表页面尝试写写这个效果 1.先贴一个 ...