数据的备份(导入和导出)

导出

分为三种类型

a)      导出表

b)     导出方案

c)      导出数据库

特别说明:

在导入和导出输入命令的时候要到Oracle 的目录下的bin目录下去导。

exp userid = scott/tiger@MLDN tables=(emp) file = e:emp.dmp;

导出表

导出其他方案的表

exp userid = scott/tiger@MLDN tables=(scott.emp) file = e:emp.dmp;

只导出表格的结构,不需要表格的数据。

只需要在前一条语句后面加上 rows = n ;

直接导出方式

如果一张表非常大,则在后面加上direct = y 就可以了,速度比较快。

exp userid = scott/tiger@MLDN tables=(scott.emp) file = e:emp.dmp   direct = y;

导出方案

导出自己的方案的时候

exp scott/tiger@MLDN owner = scott file = e:scott.dmp;

exp system/manager@MLDN owner = (system,zhuopeng) file = e:zhuopeng.dmp;    (导出了两个人的方案)。

导出数据库

要求用户有dba权限或者exp_full_database权限

exp userid = system/manager@MLDN full = y inctype = complete file = e:dmp;

导入

导入自己的表

加入scott的emp表格被损坏了,就可以再次导入回去。

imp userid = scott/tiger@MLDN tables = (emp) file =e:emp.dmp (注意,后面没有分号) ;

emp表中有一列deptno而的deptno是指向dept表,所以有阻碍键,不能导入到其他的方案中。如果没有阻碍键的关系,则可以导入到其他的方案中。

      导入方案

       Imp userid = scott/tiger file = d:xxx.dmp

       一个用户要导入其他的方案的时候需要有dba权限

      

导入数据库

原文地址:https://www.cnblogs.com/da-peng/p/5323342.html