網站首頁 編程語言 正文
1、根據時間進行恢復
此種方式需要我們大致知道執行delete語句的時間。
查詢系統當前時間:select to_char(sysdate,‘yyyy-mm-dd hh24:mi:ss’) from dual;
假設在2022-04-02 16:27:11分鐘,執行了刪除語句delete from demo ;
此時已經表中不能查詢到數據了。我們知道delete執行的時間,往前推1分鐘(delete執行時間之前都可以,越小越好,本例以1分鐘為例),執行如下語句
select * from DEMO as of timestamp to_timestamp(‘2022-04-02 16:26:11',‘yyyy-mm-dd hh24:mi:ss');
可以看到雖然當前demo表中沒有數據,但是可以查詢到demo表前1分鐘時候的數據。
恢復1:此時可以通過plsql工具的導出查詢結果功能導出sql文件,然后在重新執行sql文件中的insert語句進行數據恢復。
恢復2:執行以下sql進行數據恢復:
flashback table DEMO to timestamp to_timestamp(‘2022-04-02 16:26:11',‘yyyy-mm-dd hh24:mi:ss');
如果報錯ORA-08189:未啟用行移動功能,不能閃回表
則執行:
alter table DEMO enable row movement;
添加表行移動功能后,在進行flashback語句進行恢復
如果報錯: ORA-08194: 在實體化視圖上不允許閃回表操作;則通過下面介紹的新建臨時表的方式進行恢復。
恢復3(新建臨時表):
新建demo1表,插入需要恢復的數據
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表的數據恢復到demo表中
insert into DEMO select * from DEMO1 where not exists (select * from DEMO where DEMO.id=DEMO1.id);
恢復4(根據scn恢復):
查詢當前的scn號
select current_scn from v$database;
將scn號減少若干,執行下語句,直到能查看到我們delete的數據為止
select * from DEMO as of scn 166937913;
通過合適的scn號,執行下sql語句進行數據恢復
flashback table DEMO to scn 166937913;
總結
原文鏈接:https://blog.csdn.net/qq_34207422/article/details/123924927
相關推薦
- 2023-06-17 C語言中#define在多行宏定義出錯的原因及分析_C 語言
- 2022-10-27 詳解Python中enumerate函數的使用_python
- 2022-10-11 Nginx安裝&配置 Windows10
- 2022-08-20 Python超詳細講解內存管理機制_python
- 2022-04-10 C++?反匯編之關于Switch語句的優化措施_C 語言
- 2023-11-17 Python中調用Linux命令并獲取其返回值
- 2023-12-11 Mybatis對于多對一和一對多的處理
- 2022-06-02 GO中?分組聲明與array,?slice,?map函數_Golang
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支