exp、imp备份还原数据

逻辑备份与恢复

导出具体的分为:导出表,导出方案,导出数据库
导出使用EXP命令来完成,该命令常用的选项有:
userid:用于指定执行导出操作的用户,口令,连接字符串
tables:用于指定执行导出操作的表
ower:用于指定执行导出操作的所有者用户名
full=y:用于指定执行导出操作的方案
inctype:用于指定执行到处操作的增量
rows:用于指定执行导出操作是否要导出表中的数据
file:用于指定导出文件名
导出表(包含表中的数据)
导出自己的表
exp userid=scott/tiger@myoral tables=(table1,table2,table3...) file=d:\e1.dmp
导出其他方案的表
如果用户要导出其他方案的表,则需要dba的权限或是

exp_full_database的权限,比如system就可以导出scott的表
exp userid=system/manager@myoral tables=(scott.emp) 

file=D:\e2.dmp
导出表结构不包含表中的数据
exp userid=scott/tiger@myoracle tables=(emp) file=d:\e3.dmp rows=n
使用直接导出方法
exp userid=scott/tiger@accp tables=(emp) file=d:\e3.dmp direct=y
 这种方式比默认的的常规方式速度快,当数据量大时,可以考虑使用这样的方法;(这时需要数据库的字符集要与客户端的字符
集完全一致,否则会报错。。。。)

导出方案
导出自己的方案
exp scott/tiger@stylar owner=scott file=d:\scott.dmp;
导出其他方案
需要dba权限或者是exp_full_database权限
exp system/manger@stylar owner=(scott) file=d:\system.dmp;   -----导出多个方案的话用(scott1,scott2...)

导出数据库
导出数据库要求用户的权限dba的权限或是exp_full_database权限
exp userid=system/manager@stylar full=y inctype=complete file=D:\stylar.dmp

导入使用import工具
imp常用的选项
userid用于指定导入操作的用户名,口令,连接字符串
tables用于指定执行导入操作的表
fromuser  用于指定导入操作的源用户
touser用于指定目标用户
file 用于指定导入的文件名
full=y用于指定导入整个文件
inctype用于指定执行导入操作的增量类型
rows指定是否导入表行(数据)
ignore如果表存在,则只导入数据
log写日志到指定的路径,可以很好的查看其中的错误后缀为.log

导入表
导入自己的表
imp userid=scott/tiger@stylar tables=(emp) file=d:\xx.dmp
导入表到其他用户(要求有dba或imp_full_database)
imp userid=system/manager@stylar tables=(emp) file=d:/xx.dmp touser=scott
导入表的结构
imp userid=system/manager@stylar tables=(emp) file=d:/xx.dmp rows=n
导入数据 ----如果对象(比如表)已经存在可以只导入表的数据
imp  userid=scorr/tiger@myor tables=(emp) file=d:/xx.dmp ignore=y
导入方案
需要权限dba或者imp_full_database
导入自身的方案
imp userid=scott/tiger@stylar file=d:\xx.dmp;
导入其他方案
imp userid=system/manager@stylar file=d:\xx.dmp fromuser=system touser=scott

导入数据库
imp userid=system/manager full=y file=d:/xx.dmp
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章