exp/imp 多用户导入导出
创建用户
创建三个用户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 多用户导入导出的更多相关文章
- Oracle exp/imp数据导入导出工具基本用法
一.获取帮助 exp/imp help=y 二.数据导出 1.将数据库完全导出,设置full选项exp system/manager@orcl file=d:\db.dmp full=y 2.导出数据 ...
- exp/imp 数据库数据导出/导入
一.exp数据导出 1.导出全部数据 exp 用户名/密码@服务名 file=文件存储路径/xxx.dmp log=日志存储路径/xxx.log full=y 例: [oracle@dbservice ...
- 用exp、dmp导入导出用户到同一个实例下时,类型type会有问题
oralce的type都有唯一id,在同一个实例下,通过导入导出方法创建type时,会有唯一性问题 最好的解决方法使用impdb,expdb的方式导入导出 用oid=n解决. 实在不行,可用稍微麻烦的 ...
- [terry笔记]Oracle数据泵-schema导入导出
数据泵是10g推出的功能,个人倒数据比较喜欢用数据泵. 其导入的时候利用remap参数很方便转换表空间以及schema,并且可以忽略服务端与客户端字符集问题(exp/imp需要排查字符集). 数据泵也 ...
- oracle数据库数据导入导出步骤(入门)
oracle数据库数据导入导出步骤(入门) 说明: 1.数据库数据导入导出方法有多种,可以通过exp/imp命令导入导出,也可以用第三方工具导出,如:PLSQL 2.如果熟悉命令,建议用exp/imp ...
- Oracle数据库导入导出 imp/exp备份还原
Oracle数据导入导出imp/exp Oracle数据导入导出imp/exp 在cmd的dos命令提示符下执行,而不是在sqlplus里面,但是格式一定要类似于: imp/exp 用户名/密 ...
- linux 下使用exp/imp 或者expdp/impdp导出导入oracle数据表数据
一.环境配置 1.执行环境: exp/imp可以在客户端执行也可以在服务器端执行,在客户端执行需要先安装有oracle的客户端,如果是linux系统,就是以oracle用户登录,在控制台下执行.建议在 ...
- EXP/IMP 导出生产库表的指定数据到测试库一例
一般来讲,EXP/IMP是上一代导出导入程序,EXPDP/IMPDP是新一代的导出导入程序.对于大数据量的导出导入首选EXPDP/IMPDP,可以用到并行度,对表空间等操作上也更加的灵活.对于小数据量 ...
- Oracle 【IT实验室】数据库备份与恢复之一:exp/imp(导出与导入&装库与卸库)
1.1 基本命令 1. 获取帮助 $ exp help=y $ imp help=y 2. 三种工作方式 (1)交互式方式 $ exp // 然后按提示输入所需要的参数 ...
随机推荐
- HTML元素分类【三种类型】
在CSS中,html中的标签元素大体被分为三种不同的类型: 块状元素.内联元素(又叫行内元素)和内联块状元素. 块状元素:display:block内联元素:display:inline 内联块状 ...
- google gflag使用方法举例
前言: 1. gflag是一种命令行编码参数解析工具,开源地址: https://github.com/gflags/gflags , 在caffe框架也使用了gflag来编码解析命令行. 那么什么是 ...
- 模块(一)——re模块
re模块下的常用方法: import re ret = re.findall('a', 'eva egon yuan') # 返回所有满足匹配条件的结果,放在列表里 print(ret) #结果 : ...
- 排序算法的实现(C/C++实现)
存档: #include <iostream> #include <stdlib.h> #include <sort.h> #define maxsize 20 u ...
- [51nod1407]与与与与
有n个整数,问从他们中取出若干个数字相与之后结果是0的有多少组. 答案比较大,输出对于 1,000,000,007 (1e9+7)取模后的结果. Input 第一行输入一个整数n.(1<=n&l ...
- Mysql隔离级别,锁与MVCC
关键词:事务,ACID,隔离级别,MVCC,共享锁,排它锁 阅读本文前请先阅读http://hedengcheng.com/?p=771 http://www.hollischuang.com/arc ...
- Java应用开发中的字符集与字符编码
事出有因 在向HttpURLConnection的输出流写入内容时,因没有设置charset,导致接收方对数据的验签不一致. URL url = new URL(requestUrl); //打开连接 ...
- Eclipse安装JD-Eclipse反编译插件成功看源码
Eclipse安装JD-Eclipse反编译插件 转载 2017年12月24日 15:19:27 http://heavengate.blog.163.com/blog/static/202381 ...
- 利用脚本将EXCEl表倒入PowerDesigner中
1.Excel表格样式 2.脚本代码 '****************************************************************************** O ...
- js动态添加-表格逐行添加、删除、遍历取值
关于js对表格进行逐行添加,今天抽空整理了一下:新建一个html文件(没有编辑器的可以新建一个demo.txt文件,然后改后缀名为demo.html),把下面代码全部贴进去即可.功能包括:表格添加一行 ...