1. 程式人生 > >oracle flashback——oracle資料閃回實戰,及恢復資料到指定的時間戳——timestamp

oracle flashback——oracle資料閃回實戰,及恢復資料到指定的時間戳——timestamp

Microsoft Windows [版本 6.1.7601]
版權所有 (c) 2009 Microsoft Corporation。保留所有權利。

C:\Users\ckz>sqlplus zzjd/[email protected]/orcl as sysdba;

SQL*Plus: Release 11.2.0.1.0 Production on 星期三 5月 13 17:00:46 2015

Copyright (c) 1982, 2010, Oracle.  All rights reserved.


連線到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> SHUTDOWN IMMEDIATE;
資料庫已經關閉。
已經解除安裝資料庫。
ORACLE 例程已經關閉。
SQL> startup MOUNT;
ORACLE 例程已經啟動。

Total System Global Area 1071333376 bytes
Fixed Size                  1375792 bytes
Variable Size             713032144 bytes
Database Buffers          352321536 bytes
Redo Buffers                4603904 bytes
資料庫裝載完畢。
SQL> flashback database to scn 119272598;

閃回完成。

SQL> alter database open;
alter database open
*
第 1 行出現錯誤:
ORA-01589: 要開啟資料庫則必須使用 RESETLOGS 或 NORESETLOGS 選項


SQL> alter database open noresetlogs;
alter database open noresetlogs
*
第 1 行出現錯誤:
ORA-01610: 使用 BACKUP CONTROLFILE 選項的恢復必須已完成


SQL> alter database open resetlogs;

資料庫已更改。

SQL>

檢視可恢復的時間戳或SCN點,執行下列SQL語句:

select scn,to_char(time_dp,'yyyy-mm-dd hh24:mi:ss')from sys.smon_scn_time order by to_char(time_dp,'yyyy-mm-dd hh24:mi:ss') desc;

不推薦使用上述此方法恢復資料。

方法二:

在操作恢復資料表之前,先將要恢復的資料表清空,以免恢復時資料發生衝突

delete t_viradsl2 
insert into t_viradsl2 select * from t_viradsl2 as of timestamp to_Date('2011-01-19 15:28:00', 'yyyy-mm-dd hh24:mi:ss')