加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Flashback Table的一个案例

发布时间:2020-12-15 06:26:48 所属栏目:百科 来源:网络整理
导读:? SQL conn sys/sysadmin@keymen as sysdba; 已连接。 SQL create table mytest as select * from hr.departments; 表已创建。 SQL select count(*) from mytest; ? COUNT(*) ---------- ??????? 27 SQL select current_scn from v$database; CURRENT_SCN --
?

SQL> conn sys/sysadmin@keymen as sysdba;
已连接。
SQL> create table mytest as select * from hr.departments;

表已创建。

SQL> select count(*) from mytest;

? COUNT(*)
----------
??????? 27

SQL> select current_scn from v$database;

CURRENT_SCN
-----------
???? 825726

SQL>

SQL> insert into mytest
? 2? select * from hr.departments;

已创建27行。

SQL> select count(*) from mytest;

? COUNT(*)
----------
??????? 54

SQL> commit;

提交完成。

SQL> select count(*) from mytest;

? COUNT(*)
----------
??????? 54

SQL> select current_scn from v$database;

CURRENT_SCN
-----------
???? 825777

SQL>

SQL> flashback table mytest to scn 825726;
flashback table mytest to scn 825726
??????????????? *
第 1 行出现错误:
ORA-08185: 用户 SYS 不支持闪回


SQL>

*************************************************************************************************************************

?当某一个用户执行FLASHBACK TABLE时,给予SCN号进行闪回操作时,出项“ORA-08189: 因为未启用行移动功能,不能闪回表”错误的解决
方法:


SQL> flashback table mytest to scn 825855;
flashback table mytest to scn 825855
??????????????? *
第 1 行出现错误:
ORA-08189: 因为未启用行移动功能,不能闪回表


SQL>
*************************************************************************************************************************
SQL> conn hr/hr@keymen;
已连接。
SQL> create table mytest as select * from hr.departments;

表已创建。

SQL> select count(*) from mytest;

? COUNT(*)
----------
??????? 27

SQL> select current_scn from v$database;
select current_scn from v$database
??????????????????????? *
第 1 行出现错误:
ORA-00942: 表或视图不存在


SQL> insert into mytest
? 2? select * from hr.departments;

已创建27行。

SQL> select count(*) from mytest;

? COUNT(*)
----------
??????? 54

SQL> commit;

提交完成。

SQL> select count(*) from mytest;

? COUNT(*)
----------
??????? 54

SQL> select current_scn from v$database;
select current_scn from v$database
??????????????????????? *
第 1 行出现错误:
ORA-00942: 表或视图不存在


SQL> flashback table mytest to scn 825855;
flashback table mytest to scn 825855
??????????????? *
第 1 行出现错误:
ORA-08189: 因为未启用行移动功能,不能闪回表


SQL>


************************************************************************************************************************
问题解决如下:

alter table mytest enable row movement;

************************************************************************************************************************
SQL> create table mytest as select * from hr.departments;

表已创建。

SQL> alter table mytest enable row movement;

表已更改。

SQL> select count(*) from mytest;

? COUNT(*)
----------
??????? 27

SQL> select current_scn from v$database;
select current_scn from v$database
??????????????????????? *
第 1 行出现错误:
ORA-00942: 表或视图不存在


SQL> insert into mytest
? 2? select * from hr.departments;

已创建27行。

SQL> select count(*) from mytest;

? COUNT(*)
----------
??????? 54

SQL> commit;

提交完成。

SQL> select count(*) from mytest;

? COUNT(*)
----------
??????? 54

SQL> flashback table mytest to scn 826108;

闪回完成。

SQL> select count(*) from mytest;

? COUNT(*)
----------
??????? 27

SQL>

发现已经将后来插入的数据去掉了,数据表中又仅仅有27行数据,OK!

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读