濮阳杆衣贸易有限公司

主頁 > 知識庫 > 最簡單的Oracle數(shù)據(jù)恢復 select as of使用方法

最簡單的Oracle數(shù)據(jù)恢復 select as of使用方法

熱門標簽:車瑪仕極限運動場所地圖標注 廣東營銷智能外呼系統(tǒng)商家 N個你智能電銷機器人 電渠外呼系統(tǒng) 外呼電話系統(tǒng)用卡嗎 七日殺a19.5全地圖標注 高德地圖標注公司名字大全 騰訊地圖標注要費用嗎 地圖標注怎么保存

You perform a Flashback Query by using a SELECT statementwith an AS OF clause.You use a flashback query to restrieve data as it existed at some time in the past.The query explicitly references a past time by menasof timestamp or SCN.It returns committed data that was current at that point intime.
通過執(zhí)行一個帶as of 子句的select語句進行閃回查詢,可以閃回檢索過去某個時間存在的數(shù)據(jù),一個閃回查詢被用來重現(xiàn)過去存在過的數(shù)據(jù),這個查詢明確的引用了過去的一個時間段或SCN號,閃回查詢返回的數(shù)據(jù)都是過去某時刻已經(jīng)提交的數(shù)據(jù)。

Potential uses of Flashback Query include:
可能使用到閃回查詢的地方:
⊙Recovering lost data or undoing incorrect,committed changes.For example,if you mistakenly delete or update rows,and then commit them,you can immediately undo the mistake.
恢復丟失的數(shù)據(jù)或撤銷已經(jīng)提交的錯誤。例如如果你不小心刪除或更新了行,并且做了提交操作,你可以立刻撤銷這個錯誤。
⊙Comparing current data with the corresponding data at some time in the past.For example,you might run a daily report that shows the change in data from yesterday.You can compare the individual rows of table data or find intersections or unions of sets of rows.
比較當前數(shù)據(jù)和歷史數(shù)據(jù)的一致性。例如,你可能需要生成一份前一天數(shù)據(jù)更新的日報告,你可以分別比較表的每一行或找到行的交集和并集。
⊙Checking the state of transactional data at a particular time.For example,you could verify the account balance of a certain day.
在某個特殊時間檢查事務型數(shù)據(jù)的狀態(tài)。例如,你可以在某一天驗證賬戶收支。
⊙Simplifying the application design,by removing the need to store some kinds of temporal data.By using a Flashback Query, you can retrieve past data directly from the database.
移除某些因需求儲存的暫時數(shù)據(jù)以簡化應用設計。通過閃回查詢你可以從數(shù)據(jù)庫中直接獲取到過去的數(shù)據(jù)。
⊙Applying the packaged applications such as report generation tools to past data.
使用包裝應用(例如報表生成工具)的歷史數(shù)據(jù)
⊙Providing self-service error correction for anapplication,thereby enabling users to undo and correct their errors.
為應用提供自服務錯誤更正,因此可以讓用戶撤銷或更正他們的錯誤。
 
示例:
 
SQL> conn /as sysdba;
已連接。
SQL> set pagesize 200
SQL> select * from scott.dept;
 
    DEPTNO DNAME                        LOC
---------- ---------------------------- -------------------------
        10 ACCOUNTING                   NEW YORK
        20 RESEARCH                     DALLAS
        30 SALES                         CHICAGO
        40 OPERATIONS                   BOSTON
現(xiàn)在,我們來增加一條數(shù)據(jù),并提交:
 
SQL> insert into scott.dept values(50,'錯誤數(shù)據(jù)','CHINA');
已創(chuàng)建 1 行。
 
SQL> select * from scott.dept;


    DEPTNO DNAME                        LOC
---------- ---------------------------- -------------------------
        10 ACCOUNTING               NEW YORK
        20 RESEARCH                 DALLAS
        30 SALES                         CHICAGO
        40 OPERATIONS               BOSTON
        50 錯誤數(shù)據(jù)                     CHINA
 
SQL> commit;(2011-12-9 10:51:00)


提交完成。
正常情況下,由于已經(jīng)做了commit操作,所以rollback已經(jīng)無效了,要想得到2011-12-9 10:51:00之前的數(shù)據(jù),怎么辦?
使用timestamp時間點閃回:
SQL> select * from scott.dept as of timestamp to_timestamp('2011-12-09 10:00:00','yyyy-mm-dd hh24:mi:ss');
 
    DEPTNO DNAME                        LOC
---------- ---------------------------- -------------------------
        10  ACCOUNTING                   NEW YORK
        20  RESEARCH                      DALLAS
        30  SALES                         CHICAGO
        40  OPERATIONS                   BOSTON
閃回查詢,主要依靠表空間的undo數(shù)據(jù),如果想要追溯更久的數(shù)據(jù),就需要設置較大的undo_tablespaces大小和undo_retention。
 
如果想直接更新當前的表到歷史的某個時間狀態(tài),可以直接使用flashback關鍵字:
 
 
SQL> alter table scott.dept enable row movement;


表已更改。
 
SQL> flashback table scott.dept to timestamp to_timestamp('2011-12-09 10:00:00','yyyy-mm-dd hh24:mi:ss');


閃回完成。
 
【注意】:
閃回不是萬能的,當一個表的數(shù)據(jù)較大或時間過長時,如果沒有設置較大的閃回空間和時間,閃回操作將會失敗,可能會出現(xiàn)以下錯誤:

您可能感興趣的文章:
  • oracle drop table(表)數(shù)據(jù)恢復方法
  • oracle誤刪數(shù)據(jù)恢復方法小結(jié)
  • Oracle誤刪除表數(shù)據(jù)后的數(shù)據(jù)恢復詳解
  • 記一次Oracle數(shù)據(jù)恢復過程
  • oracle誤drop/update操作后的數(shù)據(jù)恢復測試

標簽:贛州 棗莊 玉樹 蘇州 來賓 遼寧 長沙 大興安嶺

巨人網(wǎng)絡通訊聲明:本文標題《最簡單的Oracle數(shù)據(jù)恢復 select as of使用方法》,本文關鍵詞  最簡單,的,Oracle,數(shù)據(jù)恢復,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡,涉及言論、版權(quán)與本站無關。
  • 相關文章
  • 下面列出與本文章《最簡單的Oracle數(shù)據(jù)恢復 select as of使用方法》相關的同類信息!
  • 本頁收集關于最簡單的Oracle數(shù)據(jù)恢復 select as of使用方法的相關信息資訊供網(wǎng)民參考!
  • 推薦文章
    乌鲁木齐县| 井陉县| 安泽县| 当阳市| 临湘市| 南江县| 普兰县| 大理市| 开封市| 珲春市| 岫岩| 浪卡子县| 文成县| 邻水| 台中县| 界首市| 松潘县| 邳州市| 建平县| 永顺县| 益阳市| 林芝县| 德昌县| 河源市| 衡阳县| 嘉定区| 赤峰市| 尚义县| 孟连| 盐源县| 安达市| 六盘水市| 辉南县| 富顺县| 巴林右旗| 年辖:市辖区| 固镇县| 祁阳县| 南充市| 桂东县| 黄冈市|