Flashback table

本文通过具体步骤展示了Oracle数据库中闪回表功能的使用方法。包括创建表、插入数据、提交事务及如何利用闪回功能回到过去某个时间点的状态。实验过程中详细记录了每个操作的时间点,并验证了闪回的有效性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Flashback table

 

22:18:24 scan@LEE>conn scott/tiger

已连接。

22:18:30 scott@LEE>create table test_two

22:19:13   2  (id int)

22:19:19   3  tablespace spring;

 

表已创建。

 

已用时间:  00: 00: 00.04

22:19:23 scott@LEE>insert into test_one values(1);

insert into test_one values(1)

            *

1 行出现错误:

ORA-00942: 表或视图不存在

 

 

已用时间:  00: 00: 00.03

22:19:38 scott@LEE>insert into test_two values(1);

 

已创建 1 行。

 

已用时间:  00: 00: 00.10

22:19:48 scott@LEE>insert into test_two values(2);

 

已创建 1 行。

 

已用时间:  00: 00: 00.00

22:19:51 scott@LEE>commit;

 

提交完成。

 

已用时间:  00: 00: 00.00

22:19:54 scott@LEE>alter session set nls_date_format='yyyy-mm-dd:hh24:mi:ss';

 

会话已更改。

 

已用时间:  00: 00: 00.01

22:20:08 scott@LEE>insert into test_two values(21);

 

已创建 1 行。

 

已用时间:  00: 00: 00.00

22:20:15 scott@LEE>insert into test_two values(22);

 

已创建 1 行。

 

已用时间:  00: 00: 00.00

22:20:20 scott@LEE>commit

22:20:28   2  ;

 

提交完成。

 

已用时间:  00: 00: 00.00

22:20:29 scott@LEE>select *from test_two;

 

        ID

----------

         1

         2

        21

        22

 

已用时间:  00: 00: 00.00

22:20:42 scott@LEE>flashback table test_two to timestamp

22:21:05   2  to_timestamp('2008-06-12 22:19:38','yyyy-mm-dd hh24:mi:ss');

flashback table test_two to timestamp

                *

1 行出现错误:

ORA-08189: 因为未启用行移动功能, 不能闪回表

 

 

已用时间:  00: 00: 00.04

22:21:39 scott@LEE>alter table test_two enable row movement;

 

表已更改。

 

已用时间:  00: 00: 00.03

22:22:09 scott@LEE>flashback table test_two to timestamp

22:22:14   2  to_timestamp('2008-06-12 22:19:38','yyyy-mm-dd hh24:mi:ss');

 

闪回完成。

 

已用时间:  00: 00: 00.45

22:22:17 scott@LEE>select * from test_two;

 

未选定行               //回闪到没插入数据之前,显示空,正确!

 

已用时间:  00: 00: 00.01

22:22:29 scott@LEE>flashback table test_two to timestamp

22:22:47   2  to_timestamp('2008-06-12 22:19:51','yyyy-mm-dd hh24:mi:ss');

 

闪回完成。

 

已用时间:  00: 00: 00.18

22:22:53 scott@LEE>select *from test_two;

 

未选定行             //回闪到第一次提交,未显示任何数据,说明commit是需要时间的!

 

已用时间:  00: 00: 00.00

22:23:01 scott@LEE>flashback table test_two to timestamp

22:23:08   2  to_timestamp('2008-06-12 22:20:15','yyyy-mm-dd hh24:mi:ss');

 

闪回完成。

 

已用时间:  00: 00: 00.37

22:23:37 scott@LEE>select *from test_two;

 

        ID

----------

         1

         2

 

已用时间:  00: 00: 00.00

22:23:44 scott@LEE>flashback table test_two to timestamp

22:23:52   2  to_timestamp('2008-06-12 22:20:40','yyyy-mm-dd hh24:mi:ss');

 

闪回完成。

 

已用时间:  00: 00: 00.40

22:24:19 scott@LEE>select *from test_two;

 

        ID

----------

         1

         2

        21

        22

 

已用时间:  00: 00: 00.01

22:24:29 scott@LEE>

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/11134734/viewspace-344614/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/11134734/viewspace-344614/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值