oracle 9i使用閃回查詢恢復(fù)數(shù)據(jù)庫誤刪問題
如果用戶誤刪/更新了數(shù)據(jù)后,作為用戶并沒有什么直接的方法來進(jìn)行恢復(fù),他們必須求助DBA來對數(shù)據(jù)庫進(jìn)行恢復(fù),到了Oracle9i,這一個難堪局面有所改善。Oracle 9i中提供了一項新的技術(shù)手段--閃回查詢,用戶使用閃回查詢可以及時取得誤操作前的數(shù)據(jù),并可以針對錯誤進(jìn)行相應(yīng)的恢復(fù)措施,而這一切都無需DBA干預(yù)。
因為一時手賤,生產(chǎn)上的數(shù)據(jù)被我給delete掉了。
用的是delete語句,然后很迅速的還給commit了
下面這兩個語句:
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');
------------------------------------------------------
記得大概是兩點半左右運行的delete---commit;
具體執(zhí)行流程我們可從以下幾個示例圖中體會;
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ù)據(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ù)庫操作,delete后面一定要加where”。今天無意中在網(wǎng)上看到了關(guān)于oracle誤刪除數(shù)據(jù)恢復(fù)的一條信息,發(fā)現(xiàn)的確很好使,下面就我的測試向大家匯報下。
. 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 //無數(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 //又會看到三條數(shù)據(jù)。
我們來分析下第四步,注意這句:
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這個時間點的所有數(shù)據(jù),既然
找到了,你想怎么操作都可以了。
相關(guān)文章
Oracle單行函數(shù)(字符,數(shù)值,日期,轉(zhuǎn)換)
這篇文章主要介紹了Oracle單行函數(shù)(字符,數(shù)值,日期,轉(zhuǎn)換),本文結(jié)合實例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2023-07-07安裝Oracle完整客戶端后沒有訪問接口OraOLEDB.Oracle解決辦法
這篇文章主要給大家介紹了關(guān)于安裝Oracle完整客戶端后沒有訪問接口OraOLEDB.Oracle的解決辦法,文中通過代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考解決價值,需要的朋友可以參考下2024-01-01Oracle使用RMAN備份數(shù)據(jù)庫的流程步驟
使用 RMAN(Recovery Manager)備份 Oracle 數(shù)據(jù)庫是確保數(shù)據(jù)安全和可恢復(fù)性的關(guān)鍵步驟,下面是詳細(xì)的指導(dǎo)和代碼示例,展示如何使用 RMAN 進(jìn)行數(shù)據(jù)庫備份,感興趣的小伙伴跟著小編一起來看看吧2024-09-09關(guān)于Oracle數(shù)據(jù)庫dbLink的創(chuàng)建和使用詳解
這篇文章主要介紹了關(guān)于Oracle數(shù)據(jù)庫dbLink的創(chuàng)建和使用詳解,Oracle的數(shù)據(jù)庫鏈路dbLink是一種允許在兩個不同的數(shù)據(jù)庫實例之間進(jìn)行通信和數(shù)據(jù)交換的功能,它可以讓你在一個數(shù)據(jù)庫中訪問另一個數(shù)據(jù)庫的對象和數(shù)據(jù),需要的朋友可以參考下2023-08-08