Oracle基於時間點的恢復
Oracle基於時間點的恢復能夠精確到什麼樣的精度?
這是一個需要關心的問題。
以下測試用於進行一點說明。
1.首先做好冷備份
2.建立測試資料
D:\>sqlplus "/ as sysdba"
SQL*Plus: Release 9.2.0.6.0 - Production on Mon Jan 17 11:56:43 2005
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to an idle instance.
11:56:44 SQL> startup
ORACLE instance started.
Total System Global Area 101785428 bytes
Fixed Size 454484 bytes
Variable Size 75497472 bytes
Database Buffers 25165824 bytes
Redo Buffers 667648 bytes
Database mounted.
Database opened.
11:57:01 SQL> create table test (name varchar2(20));
Table created.
Elapsed: 00:00:00.04
11:57:23 SQL> insert into test values('aaaaaaaaaaaaaaaaaaaa');
1 row created.
Elapsed: 00:00:00.00
11:57:23 SQL> insert into test values('bbbbbbbbbbbbbbbbbbbb');
1 row created.
Elapsed: 00:00:00.00
11:57:23 SQL> insert into test values('cccccccccccccccccccc');
1 row created.
Elapsed: 00:00:00.00
11:57:24 SQL> commit;
Commit complete.
Elapsed: 00:00:00.00
11:57:28 SQL>
--注意這個時間,是Commit完成時間
11:57:29 SQL> drop table test;
Table dropped.
Elapsed: 00:00:00.07
11:57:34 SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
11:57:45 SQL> exit
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.6.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.6.0 - Production
3.恢復備份資料
保留當前日誌
D:\>sqlplus "/ as sysdba"
SQL*Plus: Release 9.2.0.6.0 - Production on Mon Jan 17 11:58:04 2005
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to an idle instance.
11:58:04 SQL> startup mount;
ORACLE instance started.
Total System Global Area 101785428 bytes
Fixed Size 454484 bytes
Variable Size 75497472 bytes
Database Buffers 25165824 bytes
Redo Buffers 667648 bytes
Database mounted.
11:58:15 SQL> alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
Session altered.
Elapsed: 00:00:00.00
11:58:17 SQL> recover database until time '2005-01-17 11:57:28';
Media recovery complete.
--恢復到提交完成時刻
11:58:33 SQL> alter database open resetlogs;
Database altered.
Elapsed: 00:00:05.08
11:58:46 SQL> select * from test;
no rows selected
Elapsed: 00:00:00.00
--注意此時資料沒有被恢復。
--也就是說,落在了提交之前
4.第二個測試
D:\>sqlplus "/ as sysdba"
SQL*Plus: Release 9.2.0.6.0 - Production on Mon Jan 17 11:48:50 2005
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to an idle instance.
11:48:50 SQL> startup
ORACLE instance started.
Total System Global Area 101785428 bytes
Fixed Size 454484 bytes
Variable Size 75497472 bytes
Database Buffers 25165824 bytes
Redo Buffers 667648 bytes
Database mounted.
Database opened.
11:49:03 SQL> create table test (name varchar2(20));
Table created.
Elapsed: 00:00:00.04
11:49:32 SQL> insert into test values('aaaaaaaaaaaaaaaaaaaa');
1 row created.
Elapsed: 00:00:00.00
11:49:32 SQL> insert into test values('bbbbbbbbbbbbbbbbbbbb');
1 row created.
Elapsed: 00:00:00.00
11:49:32 SQL> insert into test values('cccccccccccccccccccc');
1 row created.
Elapsed: 00:00:00.00
11:49:32 SQL> commit;
Commit complete.
Elapsed: 00:00:00.00
11:49:34 SQL>
--注意這裡是提交時間
11:49:34 SQL>
11:49:35 SQL>
--等待時間流逝一秒
11:49:36 SQL>
11:49:37 SQL> drop table test;
Table dropped.
Elapsed: 00:00:00.06
11:49:44 SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
11:49:54 SQL> exit
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.6.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.6.0 - Production
D:\>sqlplus "/ as sysdba"
SQL*Plus: Release 9.2.0.6.0 - Production on Mon Jan 17 11:50:42 2005
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to an idle instance.
11:50:42 SQL> startup mount;
ORACLE instance started.
Total System Global Area 101785428 bytes
Fixed Size 454484 bytes
Variable Size 75497472 bytes
Database Buffers 25165824 bytes
Redo Buffers 667648 bytes
Database mounted.
11:50:59 SQL> alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
Session altered.
Elapsed: 00:00:00.00
11:51:20 SQL> recover database until time '2005-01-17 11:49:35';
Media recovery complete.
--此時恢復到提交一秒之後
11:51:22 SQL> alter database open resetlogs;
Database altered.
Elapsed: 00:00:03.09
11:51:32 SQL> select * from test;
NAME
--------------------
aaaaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbbbbb
cccccccccccccccccccc
Elapsed: 00:00:00.00
--資料得以恢復
11:51:48 SQL> drop table test;
Table dropped.
Elapsed: 00:00:00.09
11:54:40 SQL> shutdow immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
11:54:58 SQL> exit
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.6.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.6.0 - Production
結論:
Oracle能夠恢復的時間精度為1秒,但是在Oracle資料庫內部,用以產生SCN的時間點有更為精確的精度。
所以,如果你指定秒級恢復,如11:57:28,那麼秒後的精度被置00,反而就落在了提交之前。(猜測)
而等待下一秒來到時,這種情況就不會出現了。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9399028/viewspace-684352/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- mongodb 基於oplog的時間點恢復MongoDB
- ORACLE資料庫基於時間點的不完全恢復Oracle資料庫
- DM8 基於時間點的恢復
- 7.5 使用binary log 做基於時間點的恢復
- 備份與恢復:Polardb資料庫資料基於時間點恢復資料庫
- PostgreSQL 時間點恢復SQL
- 基於percona xtrabackup之innobackupex實現基於時間點資料庫恢復資料庫
- oracle基於SCN增量恢復Oracle
- 2.MongoDB 4.2副本集環境基於時間點的恢復MongoDB
- mongodb異機做時間點恢復(基於時間範圍查詢匯出oplog)MongoDB
- MySQL binlog基於時間點恢復資料失敗是什麼鬼?MySql
- 1.MongoDB 2.7主從複製(master –> slave)環境基於時間點的恢復MongoDBAST
- Oracle RMAN 表空間恢復Oracle
- 【DATAGUARD】Oracle 通過Dataguard指定恢復時間用於找回丟失資料Oracle
- 堅如磐石:TiDB 基於時間點的恢復(PiTR)特性最佳化之路丨6.5 新特性解析TiDB
- mongodb使用備份後的oplog做時間點恢復MongoDB
- PostgreSQL啟動恢復期間,恢復到的時間線的確定SQL
- 【Oracle 恢復表空間】 實驗Oracle
- 基於 Vuex 的時移操作(撤回/恢復)實現Vue
- 《PostgreSQL 指南:內幕探索》之基礎備份與時間點恢復(上)SQL
- win10恢復到上一個時間節點的方法Win10
- 使用NineData構建任意時間點(PITR)資料恢復能力資料恢復
- NBU恢復oracleOracle
- MySQL備份與恢復——基於Xtrabackup物理備份恢復MySql
- win10恢復到上一個時間節點的檔案還在嗎Win10
- Oracle案例12——NBU Oracle恢復Oracle
- PostgreSQL12中實現增量備份與任意時間點恢復SQL
- DM7使用DMRMAN恢復資料庫到指定時間點/LSN資料庫
- oracle冷備恢復Oracle
- oracle 異機恢復Oracle
- oracle資料庫損壞的恢復過程-基於IBM伺服器儲存Oracle資料庫IBM伺服器
- 基於GTID恢復誤篡改資料
- Prometheus 告警恢復時,怎麼獲取恢復時的值?Prometheus
- MySQL備份與恢復——基於MyDumper/MyLoader 邏輯備份恢復MySql
- 教你一招,告警恢復時如何拿到恢復時的值?
- Oracle RMAN恢復測試Oracle
- Oracle 不完全恢復Oracle
- MySQL備份與恢復——基於OUTFILE /LOAD DATA 邏輯備份恢復MySql
- 通過事務日誌恢復SqlServer資料庫到一個特定的時間點SQLServer資料庫