博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Oracle基于时间点的恢复
阅读量:6671 次
发布时间:2019-06-25

本文共 4751 字,大约阅读时间需要 15 分钟。

  hot3.png

Oracle基于时间点的恢复能够精确到什么样的精度?

这是一个需要关心的问题。

以下测试用于进行一点说明。

1.首先做好冷备份

2.创建测试数据

D:\>sqlplus "/ as sysdba"SQL*Plus: Release 9.2.0.6.0 - Production on Mon Jan 17 11:56:43 2005Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.Connected to an idle instance.11:56:44 SQL> startupORACLE instance started.Total System Global Area 101785428 bytesFixed Size 454484 bytesVariable Size 75497472 bytesDatabase Buffers 25165824 bytesRedo Buffers 667648 bytesDatabase mounted.Database opened.11:57:01 SQL> create table test (name varchar2(20));Table created.Elapsed: 00:00:00.0411:57:23 SQL> insert into test values('aaaaaaaaaaaaaaaaaaaa');1 row created.Elapsed: 00:00:00.0011:57:23 SQL> insert into test values('bbbbbbbbbbbbbbbbbbbb');1 row created.Elapsed: 00:00:00.0011:57:23 SQL> insert into test values('cccccccccccccccccccc');1 row created.Elapsed: 00:00:00.0011:57:24 SQL> commit;Commit complete.Elapsed: 00:00:00.0011:57:28 SQL>--注意这个时间,是Commit完成时间11:57:29 SQL> drop table test;Table dropped.Elapsed: 00:00:00.0711:57:34 SQL> shutdown immediate;Database closed.Database dismounted.ORACLE instance shut down.11:57:45 SQL> exitDisconnected from Oracle9i Enterprise Edition Release 9.2.0.6.0 - ProductionWith the Partitioning, OLAP and Oracle Data Mining optionsJServer 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 2005Copyright (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 bytesFixed Size 454484 bytesVariable Size 75497472 bytesDatabase Buffers 25165824 bytesRedo Buffers 667648 bytesDatabase mounted.11:58:15 SQL> alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';Session altered.Elapsed: 00:00:00.0011: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.0811:58:46 SQL> select * from test;no rows selectedElapsed: 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 2005Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.Connected to an idle instance.11:48:50 SQL> startupORACLE instance started.Total System Global Area 101785428 bytesFixed Size 454484 bytesVariable Size 75497472 bytesDatabase Buffers 25165824 bytesRedo Buffers 667648 bytesDatabase mounted.Database opened.11:49:03 SQL> create table test (name varchar2(20));Table created.Elapsed: 00:00:00.0411:49:32 SQL> insert into test values('aaaaaaaaaaaaaaaaaaaa');1 row created.Elapsed: 00:00:00.0011:49:32 SQL> insert into test values('bbbbbbbbbbbbbbbbbbbb');1 row created.Elapsed: 00:00:00.0011:49:32 SQL> insert into test values('cccccccccccccccccccc');1 row created.Elapsed: 00:00:00.0011:49:32 SQL> commit;Commit complete.Elapsed: 00:00:00.0011: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.0611:49:44 SQL> shutdown immediate;Database closed.Database dismounted.ORACLE instance shut down.11:49:54 SQL> exitDisconnected from Oracle9i Enterprise Edition Release 9.2.0.6.0 - ProductionWith the Partitioning, OLAP and Oracle Data Mining optionsJServer Release 9.2.0.6.0 - ProductionD:\>sqlplus "/ as sysdba"SQL*Plus: Release 9.2.0.6.0 - Production on Mon Jan 17 11:50:42 2005Copyright (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 bytesFixed Size 454484 bytesVariable Size 75497472 bytesDatabase Buffers 25165824 bytesRedo Buffers 667648 bytesDatabase mounted.11:50:59 SQL> alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';Session altered.Elapsed: 00:00:00.0011: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.0911:51:32 SQL> select * from test;NAME--------------------aaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbccccccccccccccccccccElapsed: 00:00:00.00--数据得以恢复11:51:48 SQL> drop table test;Table dropped.Elapsed: 00:00:00.0911:54:40 SQL> shutdow immediate;Database closed.Database dismounted.ORACLE instance shut down.11:54:58 SQL> exitDisconnected from Oracle9i Enterprise Edition Release 9.2.0.6.0 - ProductionWith the Partitioning, OLAP and Oracle Data Mining optionsJServer Release 9.2.0.6.0 - Production

结论:

Oracle能够恢复的时间精度为1秒,但是在Oracle数据库内部,用以产生SCN的时间点有更为精确的精度。
所以,如果你指定秒级恢复,如11:57:28,那么秒后的精度被置00,反而就落在了提交之前。

(猜测)

而等待下一秒来到时,这种情况就不会出现了。

转载于:https://my.oschina.net/90888/blog/832089

你可能感兴趣的文章
基于微软office web apps实现在线预览文档
查看>>
okToAccept: WARNING! Your cache is running out of filedescriptors
查看>>
epel
查看>>
类中关于列表的应用
查看>>
[xmind] JEE - JMS 笔记
查看>>
为android封装的百度定位组件
查看>>
List分批插入数据库
查看>>
SpringMVC数据的处理
查看>>
我的友情链接
查看>>
linux下 find+exec 命令使用
查看>>
Java的synchronized关键字:同步机制总结
查看>>
在Maven仓库中添加Oracle JDBC驱动(11g)
查看>>
linux下mysql数据库忘记密码怎么办
查看>>
挺不错的jquery幻灯片
查看>>
浅析《大数据运算》-加减乘除以及模除运算
查看>>
开始nodejs+express的学习+实践(5)
查看>>
在微信小游戏中开发一个贪食蛇
查看>>
通过class获取data-id以及相应的对象
查看>>
我的友情链接
查看>>
我的友情链接
查看>>