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 // 然后按提示输入所需要的参数 ...
随机推荐
- python 浅析IO 模型
协程:遇到IO操作就切换,但是什么时候切回去呢?怎么确定IO操作? 很多程序员可能会考虑使用"线程池"或"连接池"."线程池"旨在减少创建和 ...
- nautilus出现一闪而过现象
linux相关问题: 1.这几天在使用乌班图时,出现文件夹打开一闪而过现象,于是我试着使用命令行来启动: sudo nautilus 出现下面这一堆错误(error_info): (nautilus: ...
- deeplearning.ai 人工智能行业大师访谈 Yoshua Bengio 听课笔记
1. 如何走上人工智能的研究的?Bengio说他小时候读了很多科幻小说,1985年(64年出生,21岁)研究生阶段开始阅读神经网络方面的论文,对这个领域产生了热情. 2. 如何看深度学习这些年的发展? ...
- Windows系统下文件的概念及c语言对其的基本操作(丙)
- 【搬运】Tea算法Java实现工具类
最近在做数据加密,目标是实现平台app的数据安全性,所以准备使用AES+Base64进行加密,适逢一个特长的json串AES加密不了,于是在谷歌了各种算法,判断是否合用,参见 各种加密算法比较 一文中 ...
- Dede 删除文档同时文章中的图片的方法
首先,在"/include"目录下建立"extend.func.php"文件. 然后,将以下内容保存在"extend.func.php"文件 ...
- 见微知著——从自定义类型的operator==说起
今天打算用C++模拟一下Java的Object对象.需求很简单,通过一个自定义用户类型包装一个内建类型,并提供equals.hashCode.=和== 4种函数. 源码如下: #pragma once ...
- 新版Azure Automation Account 浅析(二) --- 更新Powershell模块和创建Runbook
前篇我们讲了怎样创建一个自动化账户以及创建时候"Run As Account"选项背后的奥秘.这一篇针对在Azure自动化账户中使用Powershell Runbook的用户讲一下 ...
- <%=pageCount %>
<%=pageCount %>,这里是指获取页面控件的值.
- python服务端多进程压测工具
本文描述一个python实现的多进程压测工具,这个压测工具的特点如下: 多进程 在大多数情况下,压测一般适用于IO密集型场景(如访问接口并等待返回),在这种场景下多线程多进程的区分并不明显(详情请参见 ...