如果用戶誤刪/更新了數(shù)據(jù)后,作為用戶并沒(méi)有什么直接的方法來(lái)進(jìn)行恢復(fù),他們必須求助DBA來(lái)對(duì)數(shù)據(jù)庫(kù)進(jìn)行恢復(fù),到了Oracle9i,這一個(gè)難堪局面有所改善。Oracle 9i中提供了一項(xiàng)新的技術(shù)手段--閃回查詢,用戶使用閃回查詢可以及時(shí)取得誤操作前的數(shù)據(jù),并可以針對(duì)錯(cuò)誤進(jìn)行相應(yīng)的恢復(fù)措施,而這一切都無(wú)需DBA干預(yù)。
因?yàn)橐粫r(shí)手賤,生產(chǎn)上的數(shù)據(jù)被我給delete掉了。
用的是delete語(yǔ)句,然后很迅速的還給commit了
下面這兩個(gè)語(yǔ)句:
ALTER TABLE tablename ENABLE row movement ;
flashback table tablename to timestamp to_timestamp('2012-09-13 13:00:00','yyyy-mm-dd hh24:mi:ss');
------------------------------------------------------
記得大概是兩點(diǎn)半左右運(yùn)行的delete---commit;
具體執(zhí)行流程我們可從以下幾個(gè)示例圖中體會(huì);
1.原表記錄
$ sqlplus eygle/eygle
SQL*Plus: Release 10.1.0.2.0 - Production on Wed Mar 30 08:52:04 2005
Copyright (c) 1982, 2004, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
SQL>select count(*) from t1;
COUNT(*)
----------
9318
2.誤刪除所有記錄
并且提交更改。
SQL>delete from t1;
9318 rows deleted.
SQL>commit;
Commit complete.
SQL>select count(*) from t1;
COUNT(*)
----------
0
3.獲得當(dāng)前SCN
如果能夠確切知道刪除之前SCN最好,如果不知道,可以進(jìn)行閃回查詢嘗試.
SQL>select dbms_flashback.get_system_change_number from dual;
GET_SYSTEM_CHANGE_NUMBER
------------------------
10671006
SQL>select count(*) from t1 as of scn 10671000;
COUNT(*)
----------
0
SQL>select count(*) from t1 as of scn 10670000;
COUNT(*)
----------
9318
我們看到在SCN=10670000時(shí),數(shù)據(jù)都在。
4.恢復(fù)數(shù)據(jù).
SQL>insert into t1 select * from t1 as of scn 10670000;
9318 rows created.
SQL>commit;
Commit complete.
SQL>select count(*) from t1;
COUNT(*)
----------
9318
其它網(wǎng)友用的教程
進(jìn)行數(shù)據(jù)庫(kù)操作,delete后面一定要加where”。今天無(wú)意中在網(wǎng)上看到了關(guān)于oracle誤刪除數(shù)據(jù)恢復(fù)的一條信息,發(fā)現(xiàn)的確很好使,下面就我的測(cè)試向大家匯報(bào)下。
. select * from t_viradsl t //查詢t_viradsl中所有的數(shù)據(jù),可以看到三條數(shù)據(jù)
. delete t_viradsl //刪除t_viradsl中所有的數(shù)據(jù),三條數(shù)據(jù)消失
. select * from t_viradsl t //無(wú)數(shù)據(jù)。
. insert into t_viradsl select * from t_viradsl as of timestamp to_Date('-- ::', 'yyyy-mm-dd hh:mi:ss') //已將誤刪除數(shù)據(jù)插入表中
. select * from t_viradsl t //又會(huì)看到三條數(shù)據(jù)。
我們來(lái)分析下第四步,注意這句:
select * from t_viradsl2 as of timestamp to_Date('2011-01-19 15:28:00', 'yyyy-mm-dd hh24:mi:ss')
什么意思呢, 找到t_viradsl2
在2011-01-19 15:28:00這個(gè)時(shí)間點(diǎn)的所有數(shù)據(jù),既然
找到了,你想怎么操作都可以了。
您可能感興趣的文章:- oracle 數(shù)據(jù)庫(kù)閃回相關(guān)語(yǔ)句介紹
- Oracle 查看表空間的大小及使用情況sql語(yǔ)句
- ORACLE 10g 安裝教程[圖文]
- Oracle數(shù)據(jù)庫(kù)下載及安裝圖文操作步驟
- Linux系統(tǒng)(X64)安裝Oracle11g完整安裝圖文教程另附基本操作
- oracle常用sql語(yǔ)句
- ORACLE 如何查詢被鎖定表及如何解鎖釋放session
- oracle sqlplus 常用命令大全
- Oracle新建用戶、角色,授權(quán),建表空間的sql語(yǔ)句
- ORACLE數(shù)據(jù)庫(kù)查看執(zhí)行計(jì)劃的方法
- oracle 查詢表名以及表的列名
- Oracle 閃回技術(shù)詳細(xì)介紹及總結(jié)