Oralce import,export 导入导出及备份

原文: http://takeme.iteye.com/blog/1622663#bc2274669

1.备份和恢复的概述

1.逻辑备份:采用 export工具将数据库对象的结构和数据导出到文件的过程。
2.逻辑恢复:值数据库对象被误操作而损坏后使用工具import利用备份文件将数据对象导    入到数据库的过程,
3.物理备份:即可在数据open 的状态下进行也可以在关闭数据库后进行,但是逻辑备份  和 恢复只能在open的状态下进行

2.导出的分类 和 语法

1.分为三种  导出表,导出方案,导出数据库 
2.导出表:如果将表导出到磁盘 
3.导出方案:如果将一个用户所有的东西 ,表 ,数据,视图... 导出到磁盘(个用户的所有都导出了) 
4.导出数据库:如果将多个方案 导出到一个磁盘 
5.语法: 
exp 命令 这命令 的选项有  
userid:用于指定执行导出操作的用户名,口令,连接字符串 
tables:用于指定执行导出操作的表 
owner:用于指定执行导出操作的方案 
full=y; 用于指定导出操作的数据库 
inctype: 用于指定导出操作的增量类型 
rows: 用于指定导出操作是否需要导出表中的数据 
file: 用于指定导出的文件名 
direct=y : 直接导出方式速度快

3.导入的分类和语法
1.导入也分为三种 导入表,导入方案 ,导入数据库 
2.语法: 
imp 命令 这命令 的选项有 
userid:用于指定执行导出操作的用户名,口令,连接字符串 
tables:用于指定执行导出操作的表 
formuser:用于指定原用户 
touser:用于指定目标用户 
file:用于指定导入的文件名 
inctype: 用于指定执行导入操作的增量类型 
rows: 用于指定导出操作是否需要导入表中的数据 
direct=y : 直接导出方式速度快 
ignore:如果表存在,则只导入数据 

准备:1.不需要登录sqlplus,直接在DOS命令下 (win+r-->cmd)
      2.在导入和导出的时候,要到oracle目录的主目录下面的bin目录下去导    (cd D:\app\Admin\product\11.1.0\db_1\BIN)
4.案例: 导出scott 的emp,emp2表

exp userid=scott/tiger@orcl tables=(emp,emp2) file=d:\e1.dmp


5.案例:只导表的结构 不要表的数据  就是只要表的定义
exp userid=sysytem/manager@orcl tables=(scott.emp)  file=d:\sysytem_scott_emp.dmp rows=n

6.案例:如果导出的表的数据量比较大 采用 直接导出方式
 exp userid=scott/tiger@oracl tables=(emp) file=d:\scott_emp.dmp direct=y

7.案例:导出其他用户方案的表,比如 system导出scott的表--需要dba的权限或者 exp_full_database 的权限
exp userid=sysytem/manager@orcl tables=(scott.emp)  file=d:\sysytem_scott_emp.dmp

8.案例:导出方案 指导出一个方案中的所有 视图,表
exp userid=scott/tiger@orcl owner=scott file=d:\kk.dmp

9.案例:导出其他方案,需要dba 权限,或者是 exp_full_database 权限 --例如system用户可以导出任何方案
exp userid=system/manager@orcl owner=scott file=d:\system_scott.dmp

10.导出数据库:是指利用export导出所有的数据库中的对象和数据,要求该用户具有dba和 exp_full_database 权限
exp  userid=system/manager@oracl full=y inctype=complete file=d:\orcl.dmp

下面是导入
11.导入自己的表 
imp userid=scott/tiger@orcl tables=(emp) file=d:\my_emp.dmp  


12.导入其他用户的表
  
imp userid=system/manager@orcl tables=(emp) file=d:\my_emp.dmp  


13.导入表到其他用户,要求有 dba权限或者 imp_full_database权限
 
imp useri=system/manager@orcl tables=(emp) file=d:\my_emp.dmp touser=scott
 

14.导入表结构   不导入数据
  
imp userid=scott/tiger@orcl tables=(emp) file=d:\my_emp.dmp rows=n  


15.导入数据 如果对象已经存在
  
imp userid=scott/tiger@orcl tables=(emp) file=d:\my_emp.dmp ignore=y 


16.导入自己的方案

imp userid=scott/tiger@orcl file=d:\xx.dmp  


17.导入其他方案 要求用户具有dba的权限

imp userid=system/manager@orcl file=d:\xx.dmp fromuser=system touser=scott  


18.导入数据库
imp userid=system/manager full=y file=d:\xxx.dmp
 

猜你喜欢

转载自zpball.iteye.com/blog/1622874
今日推荐