今天在oracle 10g 环境下测试误删某张表后怎样恢复,恢复的方法很多,我用了其中比较简单的两种:
实验:
1.模拟误删表
SQL> conn scott
Enter password: *****
Connected.
SQL> create table test1(id number);
Table created.
SQL> insert into test1 values(1);
1 row created.
SQL> select * from test1;
ID
----------
1
SQL> drop table test1;
Table dropped.
SQL> select * from test1;
select * from test1
*
ERROR at line 1:
ORA-00942: table or view does not exist
2.使用闪回恢复表
SQL> flashback table test1 to before drop;
Flashback complete.
SQL> select * from test1;
ID
----------
1
SQL>
3.假如数据库用的是逻辑备份,使用备份进行恢复表test1
[oracle@peter bak]$ imp scott/tiger file=expdat_scott20110312.dmp log=implog_scott20110312.log fromuser=scott table=test1
LRM-00101: unknown parameter name 'table'
IMP-00022: failed to process parameters, type 'IMP HELP=Y' for help
IMP-00000: Import terminated unsuccessfully
[oracle@peter bak]$ imp scott/tiger file=expdat_scott20110312.dmp log=implog_scott20110312.log fromuser=scott tables=test1
Import: Release 10.2.0.1.0 - Production on Wed May 18 17:54:41 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
Export file created by EXPORT:V10.02.01 via conventional path
import done in ZHS16GBK character set and AL16UTF16 NCHAR character set
. importing SCOTT's objects into SCOTT
. importing SCOTT's objects into SCOTT
. . importing table "TEST1" 1 rows imported
Import terminated successfully without warnings.
SQL> select * from test1;
ID
----------
1