这是有声音的视频, 请检查播放器,耳机或者音箱 声音输出设备

教程使用 Oracle 11g Release 2 版本

数据存储中, 有时会遇到数据丢失的情况,我们就需要定期做一个数据备份的工作。

在oracle中,使用EXP程序导出数据到文件进行备份, 而使用IMP就可以进行恢复。

EXP可以导出一个数据库, 也可以指定导出数据库的某个对象相关信息,

例如:数据表,表的某一列,或者表的相关信息。

===========================================

CREATE TABLE xue_sheng( id integer, xing_ming varchar(25));

INSERT INTO xue_sheng VALUES(1,'ZhanSan');

INSERT INTO xue_sheng VALUES(2,'LiSi');

COMMIT;

----------------------------------------------

下面开始进行备份: (备份学生表里的全部数据)

[oracle@localhost ~]$ exp scott/tiger

Export: Release 11.2.0.1.0 - Production on Thu Jul 15 05:30:10 2010

Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

Enter array fetch buffer size: 4096 > 4096

Export file: expdat.dmp > mydata.dmp

(2)U(sers), or (3)T(ables): (2)U > T

Export table data (yes/no): yes > yes

Compress extents (yes/no): yes > yes

Export done in US7ASCII character set and AL16UTF16 NCHAR character set

server uses AL32UTF8 character set (possible charset conversion)

About to export specified tables via Conventional Path ...

Table(T) or Partition(T:P) to be exported: (RETURN to quit) > xue_sheng

. . exporting table XUE_SHENG 2 rows exported Table(T) or Partition(T:P) to be exported: (RETURN to quit) >

Export terminated successfully without warnings.

[oracle@localhost ~]$

如果刚才没有指定备份文件的具体路径,备份文件mydata.dmp就会在当前目录下

[oracle@localhost ~]$ ls my*

mydata.dmp

=======================================

先把xue_sheng 表的数据全部删除

[oracle@localhost ~]$ sqlplus scott/tiger

SQL> select * from xue_sheng;

SQL> delete from xue_sheng;

SQL> commit;

SQL> select * from xue_sheng;

SQL> exit;

下面使用 IMP 进行数据恢复

[oracle@localhost ~]$ imp scott/tiger

Import: Release 11.2.0.1.0 - Production on Thu Jul 15 05:54:32 2010

Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production

With the Partitioning, OLAP, Data Mining and Real Application

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐