oracle闪回技术总结之闪回数据库

时间:2021-07-16 23:15:31

[实施步骤]

步骤一、设置如下的初始化参数:

Sql>小时:以分钟为单位

SQL> 点00分左右发现表被删除

切了几个归档

22:00:38SQL>:06:05 SQL> :07:01 SQL> 2015_11_24 21:52:11 drop table emp2 purge;

Sql>

SQL> selectname,scn,time from v$restore_point;

NAME                            SCN TIME

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

RS_PT                        103371424-NOV-15 10.27.58.000000000 PM

SQL> shutdownimmediate

SQL>startupmount

SQL>flashbackdatabase to restore point rs_pt;

#flashback databaseto timestamp sysdate-15/1440; (当前的系统时间之前的 15 分钟)

Flashback complete.

步骤四、以readonly 方式打开数据库

SQL> alterdatabase open read only;

Database altered.

SQL> connscott/tiger

Connected.

SQL> select *from tab;

TNAME                          TABTYPE  CLUSTERID

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

BONUS                          TABLE

DEPT                           TABLE

DEPT1                          TABLE

EMP                            TABLE

EMP2                           TABLE

SALGRADE                       TABLE

6 rows selected.

步骤五、导出dept1表

[oracle@HE1 bin]$exp scott/tiger file=/u01/apps/scott.dp1 log=scottdp1.logindexes=n  tables=dept1

Export:Release 11.2.0.1.0 - Production on Tue Nov 24 22:33:53 2015

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

Connectedto: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bitProduction

With thePartitioning, OLAP, Data Mining and Real Application Testing options

Exportdone in ZHS16GBK character set and AL16UTF16 NCHAR character set

Note:indexes on tables will not be exported

About toexport specified tables via Conventional Path ...

. .exporting table                         DEPT1          4 rows exported

Exportterminated successfully without warnings.

22:34:51 SQL> shutdown immediate

Databaseclosed.

Databasedismounted.

ORACLEinstance shut down.

22:35:13 SQL> startup mount;

ORACLEinstance started.

TotalSystem Global Area  780824576 bytes

FixedSize                    2217424 bytes

VariableSize                  465570352 bytes

DatabaseBuffers          310378496 bytes

RedoBuffers                    2658304 bytes

Databasemounted.

步骤六、恢复数据库recoverdatabase

22:35:37 SQL>recover database;

Mediarecovery complete.

步骤七、打开数据库

22:35:40 SQL>alterdatabase open;

Databasealtered.

22:35:47 SQL> conn scott/tiger

Connected.

22:36:01 SQL> select *from tab;

TNAME                              TABTYPE        CLUSTERID

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

BONUS                               TABLE

DEPT                               TABLE

DEPT2                               TABLE

EMP                               TABLE

EMP2                               TABLE

SALGRADE                       TABLE

TEST                               TABLE

7 rowsselected.

步骤八、导入dept1表

[oracle@HE1 bin]$impscott/tiger file=/u01/apps/scott.dp1 tables=dept1 fromuser=scott touser=scottignore=y

Import:Release 11.2.0.1.0 - Production on Tue Nov 24 22:39:06 2015

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

Connectedto: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bitProduction

With thePartitioning, OLAP, Data Mining and Real Application Testing options

Exportfile created by EXPORT:V11.02.00 via conventional path

importdone in ZHS16GBK character set and AL16UTF16 NCHAR character set

.importing SCOTT's objects into SCOTT

. .importing table                       "DEPT1"          4 rowsimported

Importterminated successfully without warnings.

22:36:05 SQL> select * from tab;

TNAME                              TABTYPE        CLUSTERID

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

BONUS                               TABLE

DEPT                               TABLE

DEPT1                               TABLE

DEPT2                               TABLE

EMP                               TABLE

EMP2                               TABLE

SALGRADE                       TABLE

TEST                               TABLE

8 rowsselected.

闪回数据库完成