關於oracle 9i的閃回的一個錯誤

genweihua發表於2010-02-01
      今天學習oracle 9i的閃回操作,一開始就不明白怎麼操作,開始是瞎鼓搗的,還真的找回了一次刪除了的資料,慶幸了一下,不過以後報出:ora-01446 無法讀取資料,表定義已經更改。我到網上查了一下,關於這個錯誤的資料不是很多,有一篇部落格上說要等五分鐘後才能執行閃回操作,我測試了好幾次,都失敗了。最後自己仔細想想,使用scn和timestamp,不會受到什麼時間限制,找回以前的資料,怎麼可能要等五分鐘呢?況且還是從回滾段查出資料?
      最後,我有看了一遍最開始成功的閃回的語句,發現了錯去所在,原來忘記執行excute dbms_flashback.disable這一語句。
     下邊是我學習的語句:
      Microsoft Windows XP [版本 5.1.2600]
(C) 版權所有 1985-2001 Microsoft Corp.
C:\Documents and Settings\Administrator>sqlplus/nolog
SQL*Plus: Release 9.2.0.1.0 - Production on 星期一 2月 1 15:11:53 2010
Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
SQL> conn as sysdba;
已連線。
SQL> create user test identified by test;
使用者已建立
SQL> grant connect,resource to test;
授權成功。
SQL> grant execute on dbms_flashback to test;
授權成功。
SQL> conn test/test;
已連線。
SQL> create table test as select * from v$datafiles;
create table test as select * from v$datafiles
                                   *
ERROR 位於第 1 行:
ORA-00942: 表或檢視不存在

SQL> create table test as select * from sys.dual;
表已建立。
SQL> select * from test;
D
-
X
SQL> select dbms_flashback.get_change_number from dual;
select dbms_flashback.get_change_number from dual
       *
ERROR 位於第 1 行:
ORA-00904: "DBMS_FLASHBACK"."GET_CHANGE_NUMBER": 無效的識別符號

SQL> select dbms_flashback.get_system_change_number from dual;
GET_SYSTEM_CHANGE_NUMBER
------------------------
                  304810
SQL> delete from test;
已刪除 1 行。
SQL> commit;
提交完成。
SQL> select * from  test as of scn 304810;
select * from  test as of scn 304810
               *
ERROR 位於第 1 行:
ORA-01466: 無法讀資料 - 表定義已更改

SQL> select * from  test as of scn 304810;
select * from  test as of scn 304810
               *
ERROR 位於第 1 行:
ORA-01466: 無法讀資料 - 表定義已更改

SQL> select * from  test as of scn 304810;
select * from  test as of scn 304810
               *
ERROR 位於第 1 行:
ORA-01466: 無法讀資料 - 表定義已更改

SQL> select * from  test as of scn 304810;
select * from  test as of scn 304810
               *
ERROR 位於第 1 行:
ORA-01466: 無法讀資料 - 表定義已更改

SQL> select * from  test as of scn 304810;
select * from  test as of scn 304810
               *
ERROR 位於第 1 行:
ORA-01466: 無法讀資料 - 表定義已更改

SQL> select * from test;
未選定行
SQL> select * from  test as of scn 304810;
select * from  test as of scn 304810
               *
ERROR 位於第 1 行:
ORA-01466: 無法讀資料 - 表定義已更改

SQL> set time on
15:33:37 SQL> select * from test;
未選定行
15:34:05 SQL> drop table test;
表已丟棄。
15:35:38 SQL> commit;
提交完成。
15:35:43 SQL> create table test(id int);
表已建立。
15:54:08 SQL> insert table test(1);
insert table test(1)
       *
ERROR 位於第 1 行:
ORA-00925: 缺失 INTO 關鍵字

16:00:49 SQL> insert into test values(1);
已建立 1 行。
16:01:29 SQL> insert into test values(2);
已建立 1 行。
16:01:39 SQL> insert into test values(3);
已建立 1 行。
16:01:46 SQL> execute dbms_flashback.disable;
PL/SQL 過程已成功完成。
16:03:17 SQL> create table rec as select dbms_flashback.get_system_change_number
 from dual;
表已建立。
16:05:16 SQL> select * from rec;
GET_SYSTEM_CHANGE_NUMBER
------------------------
                  314071
16:05:26 SQL> delete from test where id=1;
已刪除 1 行。
16:05:46 SQL> commit;
提交完成。
16:05:50 SQL> select * from test as of scn 314071;
        ID
----------
         1
         2
         3
16:06:38 SQL> inset into test select * from test as of scn 314071;
SP2-0734: 未知的命令開頭 "inset into..." - 忽略了剩餘的行。
16:27:33 SQL> insert into test select * from test as of scn 314071;
已建立3行。
16:27:47 SQL> select * from test;
        ID
----------
         2
         3
         1
         2
         3
16:27:59 SQL>

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22275400/viewspace-626577/,如需轉載,請註明出處,否則將追究法律責任。

相關文章