flashback table 闪回表到指定时间或SCN
发布时间:2020-12-15 17:56:22 所属栏目:百科 来源:网络整理
导读:闪回表特性: 闪回表是对闪回查询的增强。 实现表的闪回,需要使用到与撤销表空间相关的undo信息, 通过show parameter undo命令可以了解这些信息。 用户对表数据的修改操作,都记录在撤销表空间中,这为表的闪回提供了数据恢复的基
闪回表特性:闪回表是对闪回查询的增强。 实现表的闪回,需要使用到与撤销表空间相关的undo信息,通过show parameter undo命令可以了解这些信息。
用户对表数据的修改操作,都记录在撤销表空间中,这为表的闪回提供了数据恢复的基础。例如,某个修改操作在提交后被记录在撤销表空间中,保留时间为900秒,用户可以在这900秒的时间内对表进行闪回操作,从而将表中的数据恢复到修改之前的状态。
可以在线操作,
恢复到指定时间点或SCN的任何数据 自动恢复相关属性,如索引,触发器,约束 满足分布式的一致性? 满足数据一致性,所有相关对象将自动一致。 闪回表不能将表恢复到改变表结构的DDL操作之前 需要打开row movement 使用的语句: flashback table test1 to scn 22222; flashback table test1 to timestamp to_timestamp('2013/06/23 19:17:00','yyyy/mm/dd hh24:mi:ss'); 1.使用SCN闪回22:47:39 SQL> select * from test;? ?? ?? ?A ---------- ? ?? ?? ?1 ? ?? ?? ?2 ? ?? ?? ?4 22:47:45 SQL> select dbms_flashback.get_system_change_number from dual; GET_SYSTEM_CHANGE_NUMBER ------------------------ ? ?? ?? ?? ?? ???1938576 22:48:29 SQL> delete??test; 3 rows deleted 22:48:35 SQL> commit; Commit complete 22:48:37 SQL> flashback table test to scn 1938576; flashback table test to scn 1938576 ORA-08189: cannot flashback the table because row movement is not enabled 22:49:02 SQL> alter table test enable row movement; Table altered 22:49:20 SQL> flashback table test to scn 1938576; Done 22:49:28 SQL> select * from test; ? ?? ?? ?A ---------- ? ?? ?? ?1 ? ?? ?? ?2 ? ?? ?? ?4 2.使用时间戳闪回,alter table test enable row movement;上个例子已经做,这里不需要做。SQL> set time on22:51:47 SQL> select * from test; ? ?? ?? ?A ---------- ? ?? ?? ?1 ? ?? ?? ?2 ? ?? ?? ?4 22:56:03 SQL> delete test; 3 rows deleted. 22:56:07 SQL> commit; Commit complete. 22:56:10 SQL> flashback table test to timestamp to_timestamp(' 2013/06/29 22:54:00','yyyy/mm/dd hh24:mi:ss'); Flashback complete. 22:57:20 SQL> select * from test; ? ?? ?? ?A ---------- ? ?? ?? ?1 ? ?? ?? ?2 ? ?? ?? ?4 3.对表进行DDL后,无法闪回。22:57:20 SQL> select * from test;? ?? ?? ?A ---------- ? ?? ?? ?1 ? ?? ?? ?2 ? ?? ?? ?4 22:57:27 SQL> 22:59:05 SQL> drop table test; Table dropped. 22:59:16 SQL> select * from test; select * from test ? ?? ?? ?? ???* ERROR at line 1: ORA-00942: table or view does not exist 22:59:38 SQL> flashback table test to timestamp to_timestamp(' 2013/06/29 22:58:00','yyyy/mm/dd hh24:mi:ss'); flashback table test to timestamp to_timestamp('2013/06/29 22:58:00','yyyy/mm/dd hh24:mi:ss') ? ?? ?? ?? ?? ? * ERROR at line 1: ORA-00942: table or view does not exist 4.此时可以使用闪回DROP22:59:56 SQL> flashback table test to before drop; Flashback complete. 23:01:37 SQL> select * from test; ? ?? ?? ?A ---------- ? ?? ?? ?1 ? ?? ?? ?2 ? ?? ?? ?4(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |