逻辑备份之exp/imp

  exp/imp针对于逻辑结构,所以必须在数据库open阶段才能用,只是导数据,与物理文件(datafile)没有太大的关系,exp/imp操作的都是二进制文件,10g后还引进了expdp/impdp。exp/imp作用有:数据库迁移、历史数据归档、重新组织表(行迁移、高水位线的处理)、转移数据、物理备份的辅助手段。使用的方式有:交互模式、命令行模式、参数文件模式、图形模式,建议使用命令模式和参数文件模式。

一、exp

命令行模式:
[oracle]$emp -help

[oracle]$emp scott/tiger file=/u02/scott1.dmp tables=emp

导出用户:
emp scott/tiger file=/u02/scott1.dmp owner=scott

导多个表(用逗号或空格分隔开):
exp scott/tiger file=/u02/scott.dmp table=emp,dept salgrade

导多个用户:
exp system/oracle file=/u02/scottu.dmp owner=scott,hr

用sys去导:
exp \'sys/oracle as sysdba\' file=/u02/uscott.dmp owner=scott

生成log:
exp \'sys/oracle as sysdba\' file=/u02/uscott.dmp owner=scott log=/tmp/exp01.log

全库导(必须有dba权限):
exp \'sys/oracle as sysdba\' file=/u02/full1.dmp,/u02/full2.dmp filesize=200m full=y

导出的文件超过2G,会报错,怎么办?可以指定多个数据文件
exp scott/tiger file=/u02/s01.dmp,/u02/s02.dmp filesize=1g table=emp,dept salgrade log=/tmp/exp01.og
如果导出的文件大小没有1g,将只有一个到处文件

查询字符,需要转意:
exp scott/oracle file=/oracle/scott01.dmp tables=test_drop query=\"where name\=\'zhang\'\"

$ORACLE_HOME/bin/exp userid=user_name/pwd file=/back/tyds/faultimg_0901.dmp
log=/faultimg_0901.log buffer=999999999 tables=dfaultimg:IMG_LATEST feedback=10000
query=\" where pass_time \>to_date\(\'2008-12-31 18\'\,\'yyyy-mm-dd hh24\'\) and pass_time \<=to_date\(\'2009-01-31 18\'\,\'yyyy-mm-dd hh24\'\) \"

 

参数模式:
例一:[oracle]$vi p1.txt
userid=scott/tiger
file=/u02/ss01.dmp
tables=emp,dept
[oracle]$exp parfile=p1.txt

例二:[oracle]$vi p4.txt
userid=scott/tiger
file=/u02/emp10_20.dmp
tables=emp
query='where deptno in (10,20)'

例三:[oracle]$cat expsql
userid=scott/oracle
file=/oracle/scott.dmp
tables=test_drop
query="where name='zhang'"

二、imp

--先导出
[oracle]$exp scott/tiger file=/u02/scott.dmp
SQL>drop table emp purge;
SQL>drop table dept purge;
SQL>purge recyclebin;
[oracle]$imp scott/tiger file=/u02/scott.dmp tables=emp,dept

[oracle]$imp scott/tiger file=/u02/scott.dmp tables=emp ignore=y
ignore=y 表已经存在,不需要导入表结构了

以system用户导出scott用户数据,再以system导入
[oracle]$imp system/oracle file=/u02/scott.dmp owner=scott
[oracle]$exp system/oracle fromuser=scott touser=scott file=/u02/scott.dmp tables=emp,dept

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值