欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

oracle?delete誤刪除表數(shù)據(jù)后如何恢復(fù)

 更新時間:2022年06月28日 12:07:02   作者:weisian151  
最近在使用oracle數(shù)據(jù)時,一不小心把table中的數(shù)據(jù)delete掉并且已經(jīng)提交了,下面這篇文章主要給大家介紹了關(guān)于oracle?delete誤刪除表數(shù)據(jù)后如何恢復(fù)的相關(guān)資料,需要的朋友可以參考下

1、根據(jù)時間進(jìn)行恢復(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 ;

此時已經(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');

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

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

恢復(fù)2:執(zhí)行以下sql進(jìn)行數(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;

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

如果報錯: ORA-08194: 在實體化視圖上不允許閃回表操作;則通過下面介紹的新建臨時表的方式進(jìn)行恢復(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;

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

select * from DEMO as of scn 166937913;

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

flashback table DEMO to scn 166937913;

總結(jié)

到此這篇關(guān)于oracle delete誤刪除表數(shù)據(jù)后如何恢復(fù)的文章就介紹到這了,更多相關(guān)oracle delete誤刪表數(shù)據(jù)恢復(fù)內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論