oracle导入导出工具exp/imp 命令使用解析

本文深入解析了Oracle的exp/imp命令行工具的工作原理、使用方法及常见参数设置,包括全库导出、按用户导出、按表导出等操作,并详细说明了exp和imp的优缺点。同时提供了实例代码,帮助读者更好地理解和应用这些工具。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

oracle导入导出工具exp/imp 在dos,或命令行


一、exp/imp简介
exp/imp是oracle幸存的最古老的两个命令行备份工具 ,在小型数据库的转储、表空间的迁移、表的抽取、检测逻辑和物理冲突中使用非常广泛,我们可以把它作为小型数据库的物理备份后的一个逻辑备份。它可以跨平台、跨版本。


二、exp/imp工作原理:
        exp用户进程通过服务器进程连接到数据库,开启shadow进程,同时执行select语句查询数据库中的数据,通过buffer cache并通过SQL语句处理层再转移出exp导出文件,即exp进程需要占用服务器上的SGA和PGA资源。
        imp读取exp导出的.dmp文件,构造DDL语句,插入创建表与其他对象以及添加数据的语句。 


三、exp导出数据
        exp 导出数据的方式




全库导出
按用户导出
按表导出


1、查看exp 参数
[oracle@honey lost+found]$  exp help=y




2、全库导出
[oracle@honey lost+found]$  exp system/systempassword@orcl  full=y  file=/home/lost+found/full.dmp
3、按用户导出
[oracle@honey lost+found]$  exp system/systempassword@orcl  owner=olap  file=/home/lost+found/olap.dmp
4、按表导出
[oracle@honey lost+found]$  exp system/systempassword@orcl   tables=olap.D_TF_DATA_M4,olap.TB_TEST_1  file=/home/lost+found/olap_table_schem.dmp
5、只导出表结构不导出数据
[oracle@honey lost+found]$  exp system/systempassword@orcl   owner=olap  rows=n  file=/home/lost+found/olap_tables_nodata.dmp
6、exp工具的缺点




        速度慢,由于exp连接到数据库需要先select要导出的数据,再通过SGA、PGA传输给exp。
        如果此连接断开,则exp需从头开始导出,没有断点续传的功能。
        消耗服务端资源,只能服务端业务的前提下使用。


四、imp导入数据
1、查看imp参数
[oracle@honey lost+found]$  imp help=y


2、按用户导入
[oracle@honey lost+found]$  imp system/systempassword@orcl001   fromuser=olap  touser=user001  ignore=y  file=/home/lost+found/olap.dmp
注意:要确认touser=user001 这个oracle用户user001是否存在。
简言之就是:导入数据前需要在目标数据库中创建对应的用户,并给用户相应的权限和用户在自己默认表空间上的配额。
3、按表导入:
[oracle@honey lost+found]$  imp system/systempassword@orcl001  tables=tab1  fromuser=olap,user001  touser=user001,user001  ignore=y  file=/home/lost+found/olap1.dmp


自己用:
按用户导入导出
exp hnsjx/hnsjx@ORCL_vmware_rhel   owner=hnsjx  log= d:\exp_log  file=E:\successful.dmp

imp hnsjx/hnsjx@ORCL_vmware_rhel   fromuser=hnsjx  touser=hnsjx  ignore=y  log= d:\imp_log  file=e:\hnsjx_all.dmp


参考:http://chunke.blog.51cto.com/2753715/1219686

<script>window._bd_share_config={"common":{"bdsnskey":{},"bdtext":"","bdmini":"2","bdminilist":false,"bdpic":"","bdstyle":"0","bdsize":"16"},"share":{}};with(document)0[(getelementsbytagname('head')[0]||body).appendchild(createelement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new date()/36e5)];</script>
阅读(31) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~
评论热议
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值