Flashback Table的一個案例

來源:互聯網
上載者:User

 

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!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.