亚洲最大看欧美片,亚洲图揄拍自拍另类图片,欧美精品v国产精品v呦,日本在线精品视频免费

  • 站長資訊網(wǎng)
    最全最豐富的資訊網(wǎng)站

    oracle實例解析delete誤刪除表數(shù)據(jù)后如何恢復(fù)

    本篇文章給大家?guī)砹岁P(guān)于Oracle的相關(guān)知識,在使用oracle數(shù)據(jù)時,一不小心把table中的數(shù)據(jù)delete掉并且已經(jīng)提交了,下面介紹關(guān)于oracle delete誤刪除表數(shù)據(jù)后如何恢復(fù)的相關(guān)資料,希望對大家有幫助。

    oracle實例解析delete誤刪除表數(shù)據(jù)后如何恢復(fù)

    推薦教程:《Oracle視頻教程》

    根據(jù)時間進行恢復(fù)

    此種方式需要我們大致知道執(zhí)行delete語句的時間。

    查詢系統(tǒng)當(dāng)前時間:select to_char(sysdate,‘yyyy-mm-dd hh24:mi:ss’) from dual;

    假設(shè)在2022-04-02 16:27:11分鐘,執(zhí)行了刪除語句
    delete from demo ;

    oracle實例解析delete誤刪除表數(shù)據(jù)后如何恢復(fù)

    此時已經(jīng)表中不能查詢到數(shù)據(jù)了。我們知道delete執(zhí)行的時間,往前推1分鐘(delete執(zhí)行時間之前都可以,越小越好,本例以1分鐘為例),執(zhí)行如下語句

    select * from DEMO as of timestamp to_timestamp(‘2022-04-02 16:26:11',‘yyyy-mm-dd hh24:mi:ss');

    oracle實例解析delete誤刪除表數(shù)據(jù)后如何恢復(fù)

    可以看到雖然當(dāng)前demo表中沒有數(shù)據(jù),但是可以查詢到demo表前1分鐘時候的數(shù)據(jù)。

    恢復(fù)1:此時可以通過plsql工具的導(dǎo)出查詢結(jié)果功能導(dǎo)出sql文件,然后在重新執(zhí)行sql文件中的insert語句進行數(shù)據(jù)恢復(fù)。

    恢復(fù)2:執(zhí)行以下sql進行數(shù)據(jù)恢復(fù):

    flashback table DEMO to timestamp to_timestamp(‘2022-04-02 16:26:11',‘yyyy-mm-dd hh24:mi:ss');

    如果報錯ORA-08189:未啟用行移動功能,不能閃回表

    則執(zhí)行:

    alter table DEMO enable row movement;

    添加表行移動功能后,在進行flashback語句進行恢復(fù)

    如果報錯: ORA-08194: 在實體化視圖上不允許閃回表操作;則通過下面介紹的新建臨時表的方式進行恢復(fù)。

    恢復(fù)3(新建臨時表):

    新建demo1表,插入需要恢復(fù)的數(shù)據(jù)

    create table DEMO1 as select * from DEMO as of timestamp to_timestamp(‘2022-04-02 16:30:11',‘yyyy-mm-dd hh24:mi:ss');

    將demo1表的數(shù)據(jù)恢復(fù)到demo表中

    insert into DEMO select * from DEMO1 where not exists (select * from DEMO where DEMO.id=DEMO1.id);

    恢復(fù)4(根據(jù)scn恢復(fù)):

    查詢當(dāng)前的scn號

    select current_scn from v$database;

    oracle實例解析delete誤刪除表數(shù)據(jù)后如何恢復(fù)

    將scn號減少若干,執(zhí)行下語句,直到能查看到我們delete的數(shù)據(jù)為止

    select * from DEMO as of scn 166937913;

    通過合適的scn號,執(zhí)行下sql語句進行數(shù)據(jù)恢復(fù)

    flashback table DEMO to scn 166937913;

    推薦教程:《Oracle視頻教程》

    贊(0)
    分享到: 更多 (0)
    網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號