(f)--閃回恢復區---實踐2---閃回表(閃回DML部分資料會用到閃回查詢)
Flashback table 閃表
回收站功能---> 將表改名而已 alter table Z1 rename to ZZ1;
回收站(recyclebin),是一個虛擬的容器,依舊在表的原表空間內,用於存放所有被刪除的物件的資料字典
特點:
線上操作
自動恢復相關屬性,如索引、觸發器等
滿足資料一致性,所有相關物件將自動一致
新資料空間需求不足 系統自動清理回收站
只能閃drop 不能閃truncate
回收站功能---> 將表改名而已 alter table Z1 rename to ZZ1;
回收站(recyclebin),是一個虛擬的容器,依舊在表的原表空間內,用於存放所有被刪除的物件的資料字典
特點:
線上操作
自動恢復相關屬性,如索引、觸發器等
滿足資料一致性,所有相關物件將自動一致
新資料空間需求不足 系統自動清理回收站
只能閃drop 不能閃truncate
1、閃回整個刪除的表 --基於undo表空間有資料庫情況下 測試如果將undo表空間offline ,drop table T1, flashback table T1 to before drop;是成功的,後期查詢是不行的,也就證明了“閃回查詢是undo,而閃回表是回收站,閃回資料庫則要依賴閃回區” recover datafile 4,alter database datafile 'E:\APP\ADMINISTRATOR\ORADATA\ORACLE11G\USERS01.DBF' online; SELECT FILE#, STATUS,RECOVER, NAME,error FROM V$DATAFILE_HEADER;資料檔案的狀態
2、閃回部分的DML操作的表 --要基於undo表空間裡的內容,只要undo內容足夠就可以反覆flashback ,恢復某個時間點和scn號
測試1: --->整個表被刪除的恢復, 資料檔案空間(auto/nonauto)情況下,recyclebin變動情況
SCOTT@ora10g> drop table t4;
Table dropped.
SCOTT@ora10g> select * from tab;
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
DEPT TABLE
EMP TABLE
BONUS TABLE
SALGRADE TABLE
T5 TABLE
T3 TABLE
T2 TABLE
BIN$mKoYM02QCojgQAB/AQAvyw==$0 TABLE
8 rows selected.
SCOTT@ora10g> 不放入回收站 直接刪除
SCOTT@ora10g> drop table t3 purge;
Table dropped.
SCOTT@ora10g>
從回收站中恢復表
SCOTT@ora10g> show recycl
ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE DROP TIME
---------------- ------------------------------ ------------ -------------------
T4 BIN$mKoYM02QCojgQAB/AQAvyw==$0 TABLE 2010-12-31:07:32:09
SCOTT@ora10g> flashback table t4 to before drop;
Flashback complete.
SCOTT@ora10g> select * from tab;
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
DEPT TABLE
EMP TABLE
BONUS TABLE
SALGRADE TABLE
T5 TABLE
T4 TABLE
T2 TABLE
7 rows selected.
SCOTT@ora10g>
多次刪除同一個表的恢復
SCOTT@ora10g> flashback table "BIN$mKoYM02RCojgQAB/AQAvyw==$0" to before drop;
Flashback complete.
SCOTT@ora10g>
SCOTT@ora10g> flashback table t4 to before drop rename to t7;
Flashback complete.
SCOTT@ora10g>
清空回收站
SCOTT@ora10g> sho recycle;
ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE DROP TIME
---------------- ------------------------------ ------------ -------------------
T4 BIN$mKoYM02UCojgQAB/AQAvyw==$0 TABLE 2010-12-31:08:35:06
SCOTT@ora10g> purge table t4;
Table purged.
SCOTT@ora10g> sho recycle;
SCOTT@ora10g> purge recyclebin;
帶索引的表的閃回時 索引名稱不會還原 要手動改
SQL> SELECT INDEX_NAME,TABLE_NAME FROM DBA_INDEXES WHERE TABLE_NAME='T2';
INDEX_NAME TABLE_NAME
------------------------------ ------------------------------
IND_T2 T2
SQL> drop table t2;
Table dropped.
SQL> select object_name,original_name,type from recyclebin;
OBJECT_NAME ORIGINAL_NAME TYPE
------------------------------ -------------------------------- -------------------------
BIN$nTKLacW7QjzgQAoKCgoJog==$0 IND_T2 INDEX
BIN$nTKLacW8QjzgQAoKCgoJog==$0 T2 TABLE
SQL> flashback table t2 to before drop;
Flashback complete.
SQL> SELECT INDEX_NAME,TABLE_NAME FROM DBA_INDEXES WHERE TABLE_NAME='T2';
INDEX_NAME TABLE_NAME
------------------------------ ------------------------------
BIN$nTKLacW7QjzgQAoKCgoJog==$0 T2
SQL> ALTER INDEX "BIN$nTKLacW7QjzgQAoKCgoJog==$0" RENAME TO "IND_T2";
Index altered.
SQL> SELECT INDEX_NAME,TABLE_NAME FROM DBA_INDEXES WHERE TABLE_NAME='T2';
INDEX_NAME TABLE_NAME
------------------------------ ------------------------------
IND_T2 T2
SQL>
當新資料增長 表空間容量不足時 回收站的內容會自動被系統清理
SQL> create tablespace mytbs datafile '/u01/oracle/oradata/ora10g/mytbs01.dbf' size 2M;
Tablespace created.
SQL> create table t1 tablespace mytbs as select * from scott.emp;
Table created.
SQL> drop table t1;
Table dropped.
SQL> show recycle;
ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE DROP TIME
---------------- ------------------------------ ------------ -------------------
T1 BIN$nTKLacW1QjzgQAoKCgoJog==$0 TABLE 2011-02-27:01:11:59
SQL> create table t1 tablespace mytbs as select * from scott.emp;
Table created.
SQL> show recycle;
ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE DROP TIME
---------------- ------------------------------ ------------ -------------------
T1 BIN$nTKLacW1QjzgQAoKCgoJog==$0 TABLE 2011-02-27:01:11:59
SQL> insert into t1 select * from t1;
14 rows created.
SQL> /
...........
1792 rows created.
SQL> show recycle;
ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE DROP TIME
---------------- ------------------------------ ------------ -------------------
T1 BIN$nTKLacW1QjzgQAoKCgoJog==$0 TABLE 2011-02-27:01:11:59
SQL> insert into t1 select * from t1;
3584 rows created.
SQL> /
7168 rows created.
SQL> /
insert into t1 select * from t1
*
ERROR at line 1:
ORA-01653: unable to extend table SYS.T1 by 128 in tablespace MYTBS
SQL> show recycle;
SQL>
即使資料檔案可以擴充 也會清除回收站
SQL> alter database datafile '/u01/oracle/oradata/ora10g/mytbs01.dbf' autoextend on ;
Database altered.
SQL> drop table t1;
Table dropped.
SQL> show recyc;
ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE DROP TIME
---------------- ------------------------------ ------------ -------------------
T1 BIN$nTKLacW2QjzgQAoKCgoJog==$0 TABLE 2011-02-27:01:21:27
SQL> create table t1 tablespace mytbs as select * from scott.emp;
Table created.
SQL> show recyc;
ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE DROP TIME
---------------- ------------------------------ ------------ -------------------
T1 BIN$nTKLacW2QjzgQAoKCgoJog==$0 TABLE 2011-02-27:01:21:27
SQL> insert into t1 select * from t1;
14 rows created.
SQL> /
...................
3584 rows created.
SQL> show recyc;
ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE DROP TIME
---------------- ------------------------------ ------------ -------------------
T1 BIN$nTKLacW2QjzgQAoKCgoJog==$0 TABLE 2011-02-27:01:21:27
SQL> /
7168 rows created.
SQL> show recyc;
ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE DROP TIME
---------------- ------------------------------ ------------ -------------------
T1 BIN$nTKLacW2QjzgQAoKCgoJog==$0 TABLE 2011-02-27:01:21:27
SQL> /
14336 rows created.
SQL> show recyc;
SQL>
有些應用,會頻繁地建立並刪除表,如果這個時候開啟這項功能,就會在回收站中產生很多的垃圾資訊,如果需要,可以根據情況關閉這項功能。
[啟用&關閉回收站]
ALTER SESSION SET recyclebin = ON;
ALTER SYSTEM SET recyclebin = ON;
ALTER SESSION SET recyclebin = OFF;
ALTER SYSTEM SET recyclebin = OFF;
Table dropped.
SCOTT@ora10g> select * from tab;
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
DEPT TABLE
EMP TABLE
BONUS TABLE
SALGRADE TABLE
T5 TABLE
T3 TABLE
T2 TABLE
BIN$mKoYM02QCojgQAB/AQAvyw==$0 TABLE
8 rows selected.
SCOTT@ora10g> 不放入回收站 直接刪除
SCOTT@ora10g> drop table t3 purge;
Table dropped.
SCOTT@ora10g>
從回收站中恢復表
SCOTT@ora10g> show recycl
ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE DROP TIME
---------------- ------------------------------ ------------ -------------------
T4 BIN$mKoYM02QCojgQAB/AQAvyw==$0 TABLE 2010-12-31:07:32:09
SCOTT@ora10g> flashback table t4 to before drop;
Flashback complete.
SCOTT@ora10g> select * from tab;
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
DEPT TABLE
EMP TABLE
BONUS TABLE
SALGRADE TABLE
T5 TABLE
T4 TABLE
T2 TABLE
7 rows selected.
SCOTT@ora10g>
多次刪除同一個表的恢復
SCOTT@ora10g> flashback table "BIN$mKoYM02RCojgQAB/AQAvyw==$0" to before drop;
Flashback complete.
SCOTT@ora10g>
SCOTT@ora10g> flashback table t4 to before drop rename to t7;
Flashback complete.
SCOTT@ora10g>
清空回收站
SCOTT@ora10g> sho recycle;
ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE DROP TIME
---------------- ------------------------------ ------------ -------------------
T4 BIN$mKoYM02UCojgQAB/AQAvyw==$0 TABLE 2010-12-31:08:35:06
SCOTT@ora10g> purge table t4;
Table purged.
SCOTT@ora10g> sho recycle;
SCOTT@ora10g> purge recyclebin;
帶索引的表的閃回時 索引名稱不會還原 要手動改
SQL> SELECT INDEX_NAME,TABLE_NAME FROM DBA_INDEXES WHERE TABLE_NAME='T2';
INDEX_NAME TABLE_NAME
------------------------------ ------------------------------
IND_T2 T2
SQL> drop table t2;
Table dropped.
SQL> select object_name,original_name,type from recyclebin;
OBJECT_NAME ORIGINAL_NAME TYPE
------------------------------ -------------------------------- -------------------------
BIN$nTKLacW7QjzgQAoKCgoJog==$0 IND_T2 INDEX
BIN$nTKLacW8QjzgQAoKCgoJog==$0 T2 TABLE
SQL> flashback table t2 to before drop;
Flashback complete.
SQL> SELECT INDEX_NAME,TABLE_NAME FROM DBA_INDEXES WHERE TABLE_NAME='T2';
INDEX_NAME TABLE_NAME
------------------------------ ------------------------------
BIN$nTKLacW7QjzgQAoKCgoJog==$0 T2
SQL> ALTER INDEX "BIN$nTKLacW7QjzgQAoKCgoJog==$0" RENAME TO "IND_T2";
Index altered.
SQL> SELECT INDEX_NAME,TABLE_NAME FROM DBA_INDEXES WHERE TABLE_NAME='T2';
INDEX_NAME TABLE_NAME
------------------------------ ------------------------------
IND_T2 T2
SQL>
當新資料增長 表空間容量不足時 回收站的內容會自動被系統清理
SQL> create tablespace mytbs datafile '/u01/oracle/oradata/ora10g/mytbs01.dbf' size 2M;
Tablespace created.
SQL> create table t1 tablespace mytbs as select * from scott.emp;
Table created.
SQL> drop table t1;
Table dropped.
SQL> show recycle;
ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE DROP TIME
---------------- ------------------------------ ------------ -------------------
T1 BIN$nTKLacW1QjzgQAoKCgoJog==$0 TABLE 2011-02-27:01:11:59
SQL> create table t1 tablespace mytbs as select * from scott.emp;
Table created.
SQL> show recycle;
ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE DROP TIME
---------------- ------------------------------ ------------ -------------------
T1 BIN$nTKLacW1QjzgQAoKCgoJog==$0 TABLE 2011-02-27:01:11:59
SQL> insert into t1 select * from t1;
14 rows created.
SQL> /
...........
1792 rows created.
SQL> show recycle;
ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE DROP TIME
---------------- ------------------------------ ------------ -------------------
T1 BIN$nTKLacW1QjzgQAoKCgoJog==$0 TABLE 2011-02-27:01:11:59
SQL> insert into t1 select * from t1;
3584 rows created.
SQL> /
7168 rows created.
SQL> /
insert into t1 select * from t1
*
ERROR at line 1:
ORA-01653: unable to extend table SYS.T1 by 128 in tablespace MYTBS
SQL> show recycle;
SQL>
即使資料檔案可以擴充 也會清除回收站
SQL> alter database datafile '/u01/oracle/oradata/ora10g/mytbs01.dbf' autoextend on ;
Database altered.
SQL> drop table t1;
Table dropped.
SQL> show recyc;
ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE DROP TIME
---------------- ------------------------------ ------------ -------------------
T1 BIN$nTKLacW2QjzgQAoKCgoJog==$0 TABLE 2011-02-27:01:21:27
SQL> create table t1 tablespace mytbs as select * from scott.emp;
Table created.
SQL> show recyc;
ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE DROP TIME
---------------- ------------------------------ ------------ -------------------
T1 BIN$nTKLacW2QjzgQAoKCgoJog==$0 TABLE 2011-02-27:01:21:27
SQL> insert into t1 select * from t1;
14 rows created.
SQL> /
...................
3584 rows created.
SQL> show recyc;
ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE DROP TIME
---------------- ------------------------------ ------------ -------------------
T1 BIN$nTKLacW2QjzgQAoKCgoJog==$0 TABLE 2011-02-27:01:21:27
SQL> /
7168 rows created.
SQL> show recyc;
ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE DROP TIME
---------------- ------------------------------ ------------ -------------------
T1 BIN$nTKLacW2QjzgQAoKCgoJog==$0 TABLE 2011-02-27:01:21:27
SQL> /
14336 rows created.
SQL> show recyc;
SQL>
有些應用,會頻繁地建立並刪除表,如果這個時候開啟這項功能,就會在回收站中產生很多的垃圾資訊,如果需要,可以根據情況關閉這項功能。
[啟用&關閉回收站]
ALTER SESSION SET recyclebin = ON;
ALTER SYSTEM SET recyclebin = ON;
ALTER SESSION SET recyclebin = OFF;
ALTER SYSTEM SET recyclebin = OFF;
測試2: --->部分的DML操作恢復
update t1 set id=1; 預設15分鐘內就可閃回show parameter undo_retention; 該引數儲存了回滾段資料儲存的秒時間
可以閃表到 undo_retention限制歷史時間內:(10g開始正式支援)
alter table t1 enable row movement; 開啟表的行移動(實現完之後再disable)
flashback table t1 to timestamp(sysdate-15/1440); 從回滾取出資料或者(to scn XX )
可以閃表到 undo_retention限制歷史時間內:(10g開始正式支援)
alter table t1 enable row movement; 開啟表的行移動(實現完之後再disable)
flashback table t1 to timestamp(sysdate-15/1440); 從回滾取出資料或者(to scn XX )
alter table t1 disable row movement;
SQL> create table t1 as select OWNER,OBJECT_NAME from all_objects where rownum<2;
SQL> select * from t1;
OWNER OBJECT_NAME
------------------------------ ------------------------------
SYS ICOL$
SQL> select * from t1;
OWNER OBJECT_NAME
------------------------------ ------------------------------
SYS ICOL$
SQL> create index i_objectidon on t1 (owner);
SQL> select a.table_owner,a.table_name,a.index_name,a.status from user_indexes a where a.table_name='T1';
TABLE_ TABLE_N INDEX_NAME STATUS
------ ------- ------------------------------ --------
TEST1 T1 I_OBJECTIDON VALID
TEST1 T1 PK_T1 VALID
SQL> select a.table_owner,a.table_name,a.index_name,a.status from user_indexes a where a.table_name='T1';
TABLE_ TABLE_N INDEX_NAME STATUS
------ ------- ------------------------------ --------
TEST1 T1 I_OBJECTIDON VALID
TEST1 T1 PK_T1 VALID
SQL> select current_scn from v$database; ---->--DML 操作前scn
CURRENT_SCN
-----------
6213312590
CURRENT_SCN
-----------
6213312590
SQL> select to_char(sysdate,'yyyy-mm-dd HH24:MI:SS') from dual; ---DML 操作前時間
SYSDATE
-------------------
2013-04-11 17.34.47
SYSDATE
-------------------
2013-04-11 17.34.47
SQL> insert into t1 values('A','B');
已建立 1 行。
SQL> commit;
提交完成。
SQL> select * from t1 as of timestamp sysdate-10/1440 ;
OWNER OBJECT_NAME
------------------------------ ------------------------------
SYS ICOL$
已建立 1 行。
SQL> commit;
提交完成。
SQL> select * from t1 as of timestamp sysdate;
OWNER OBJECT_NAME
------------------------------ ------------------------------
A B
SYS ICOL$
OWNER OBJECT_NAME
------------------------------ ------------------------------
A B
SYS ICOL$
SQL> select * from t1 as of timestamp sysdate-10/1440 ;
OWNER OBJECT_NAME
------------------------------ ------------------------------
SYS ICOL$
SQL> select * from t1 as of scn 6213312590; ---DML 操作前scn
OWNER OBJECT_NAME
------------------------------ ------------------------------
SYS ICOL$
SQL> select current_scn from v$database; ---DML 操作後scn
CURRENT_SCN
-----------
6213312684
SQL> select * from t1 as of scn 6213312684; ---DML 操作後scn的資料
OWNER OBJECT_NAME
------------------------------ ------------------------------
A B
SYS ICOL$
都用起來很方便 但as of timestamp缺點是時間精缺度不足
比如問題發生後,你每次執行閃查都是以當前時間為基線做運算
當前時間又在不斷流逝 所以說精確度不足
所以建議採用 as of scn
SCN歷史的數字是固定的.這使我們查詢就更容易定點了
獲取當前系統SCN的方法
9I; SQL> select dbms_flashback.get_system_change_number from dual;
OWNER OBJECT_NAME
------------------------------ ------------------------------
SYS ICOL$
SQL> select current_scn from v$database; ---DML 操作後scn
CURRENT_SCN
-----------
6213312684
SQL> select * from t1 as of scn 6213312684; ---DML 操作後scn的資料
OWNER OBJECT_NAME
------------------------------ ------------------------------
A B
SYS ICOL$
都用起來很方便 但as of timestamp缺點是時間精缺度不足
比如問題發生後,你每次執行閃查都是以當前時間為基線做運算
當前時間又在不斷流逝 所以說精確度不足
所以建議採用 as of scn
SCN歷史的數字是固定的.這使我們查詢就更容易定點了
獲取當前系統SCN的方法
9I; SQL> select dbms_flashback.get_system_change_number from dual;
GET_SYSTEM_CHANGE_NUMBER
------------------------
6213312926
6213312926
10G:SQL> select current_scn from v$database;
CURRENT_SCN
-----------
6213312924
檢視SCN和時間對應關係
SQL> select SCN,TIME_DP from smon_scn_time; --只有sys使用者可以查詢
這個表中儲存 每間隔5分鐘儲存一次
每隔5分鐘,系統產生一次系統時間標記與scn的匹配並存入sys.smon_scn_time表,
該表中記錄了最近1440個系統時間標記與scn的匹配記錄,由於該表只維護了最近的1440條記錄,
因此如果使用as of timestamp的方式則只能flashback最近5天內的資料
(假設系統是在持續不斷執行並無中斷或關機重啟之類操作的話)。
所以在Oracle9iR2中,表屬性修改時間和flashback時間差至少應為5分鐘。否則就會出現ORA-01466錯誤。
到了10G後雖然這個表記錄的還是間隔5分,但多了TIM_SCN_MAP欄位記錄
系統每3-6秒鐘左右更新一次SCN與時間的對應 這個時間對人類操作可以忽略了
時間和scn互換函式
SQL>SQL> select scn_to_timestamp((select current_scn from v$database)) from dual;
SCN_TO_TIMESTAMP((SELECTCURRENT_SCNFROMV$DATABASE))
---------------------------------------------------------------------------
11-4月 -13 05.51.17.000000000 下午
SQL> select timestamp_to_scn((select scn_to_timestamp((select current_scn from v$database)) from dual)) SCN,(select current_scn from v$database) 當前SCN from dual;
SCN 當前SCN
---------- ----------
6213313313 6213313319
恢復; 閃回DML資料是使用回滾段進行恢復
SQL> flashback table t1 to scn 6213312590;
*
第 1 行出現錯誤:
ORA-08189: 因為未啟用行移動功能, 不能閃回表
*
第 1 行出現錯誤:
ORA-08189: 因為未啟用行移動功能, 不能閃回表
SQL> alter table t enable row movement; ----> rowmove就是個允許Oracle修改rowid開關,插入資料時會為該條資料分配唯一rowid並且不變,要啟用閃回功能必須開啟可修改rowid功能開啟之後如果行移動了,就會有影響,如果行沒移動,就沒有影響
表已更改。
SQL> flashback table t1 to scn 6213312590; ----->恢復到增加前的scn
SQL> select * from t1 ;
OWNER OBJECT_NAME
------------------------------ ------------------------------
SYS ICOL$
SQL> flashback table t1 to scn 6213312684; ----->取消剛剛的恢復 恢復到增加後的scn
閃回完成。
SQL> select * from t1 ;
OWNER OBJECT_NAME
------------------------------ ------------------------------
A B
SYS ICOL$
SQL> flashback table t1 to timestamp(sysdate-1/10); ----->恢復到增加前的時間段
閃回完成。
SQL> select * from t1 ;
OWNER OBJECT_NAME
------------------------------ ------------------------------
SYS ICOL$
SQL> flashback table t1 to timestamp(sysdate-10/1400); ---->取消剛剛的恢復 恢復到增加後的scn
閃回完成。
SQL> select * from t1 ;
OWNER OBJECT_NAME
------------------------------ ------------------------------
A B
SYS ICOL$
閃回完成。
SQL> select * from t1 ;
OWNER OBJECT_NAME
------------------------------ ------------------------------
SYS ICOL$
SQL> flashback table t1 to timestamp(sysdate-10/1400); ---->取消剛剛的恢復 恢復到增加後的scn
閃回完成。
SQL> select * from t1 ;
OWNER OBJECT_NAME
------------------------------ ------------------------------
A B
SYS ICOL$
結論得出:只要undo內容足夠就可以反覆flashback ,恢復某個時間點和scn號
測試:rowmove就是個開關,開啟之後如果行移動了,就會有影響,如果行沒移動,就沒有影響
SQL> select t.*, t.rowid from T1 t ;
OWNER OBJECT_NAME ROWID
------------------------------ ------------------------------ ------------------
SYS ICOL$ AAAY/wAAEAAABkzAAC
OWNER OBJECT_NAME ROWID
------------------------------ ------------------------------ ------------------
SYS ICOL$ AAAY/wAAEAAABkzAAC
SQL> delete from t1;
已刪除 1 行。
SQL> commit;
提交完成。
已刪除 1 行。
SQL> commit;
提交完成。
SQL> flashback table t1 to timestamp(sysdate-1/10);
閃回完成。
SQL> select t.*, t.rowid from T1 t;
OWNER OBJECT_NAME ROWID
------------------------------ ------------------------------ ------------------
SYS ICOL$ AAAY/wAAEAAABkzAAA
SQL>
閃回完成。
SQL> select t.*, t.rowid from T1 t;
OWNER OBJECT_NAME ROWID
------------------------------ ------------------------------ ------------------
SYS ICOL$ AAAY/wAAEAAABkzAAA
SQL>
結論:enable row movement 可能導致索引失效,觸發器一定會失效(網上說的還未測試),行移動就會有影響,如果沒移動,就沒影響
疑問:
恢復區沒有flashback_on 為什麼可以恢復表和恢復DML表?
答:只有 flashback database操作依賴於flashback log (儲存在flashback area中,需要資料庫 flashback_on)
其它的 flashback操作(比如flashback query )(flashback tables/DML tables)都依賴於 undo資料,與資料庫flashback on還是 off無關。
其它的 flashback操作(比如flashback query )(flashback tables/DML tables)都依賴於 undo資料,與資料庫flashback on還是 off無關。
V$FLASHBACK_DATABASE_LOG顯示閃回資料的資訊,用來評估當前負載下需要的閃回空間
Name Description
---------------------------------- --------------------------------------------------
OLDEST_FLASHBACK_SCN Lowest system change number (SCN) in the flashback data, for any incarnation 閃回資料最小的 scn
OLDEST_FLASHBACK_TIME Time of the lowest SCN in the flashback data, for any incarnation閃回資料最小的時間
RETENTION_TARGET Target retention time (in minutes) 閃回保留時間
FLASHBACK_SIZE Current size (in bytes) of the flashback data 閃回資料大小
ESTIMATED_FLASHBACK_SIZE Estimated size of flashback data needed for the current target retention 評估滿足當前閃回保留時間,需要的閃回空間的大小
V$FLASHBACK_DATABASE_STAT 顯示資料庫收集到的閃回資訊
Name Description
---------------------------------- --------------------------------------------------
BEGIN_TIME Beginning of the time interval 一段時間間隔的起始時間
END_TIME End of the time interval 一段時間間隔的結束時間
FLASHBACK_DATA Number of bytes of flashback data written during the interval 一段時間內閃回資料的大小 (bytes)
DB_DATA Number of bytes of database data read and written during the interval一段時間內資料庫讀寫大小 (bytes)
REDO_DATA Number of bytes of redo data written during the interval 一段時間內 redo 資料的大小(bytes)
ESTIMATED_FLASHBACK_SIZE Value of ESTIMATED_FLASHBACK_SIZE in V$FLASHBACK_DATABASE_LOG at the end of the time interval 一段時間間隔的結束時,評估需要閃回空間的大小
未開閃回,drop table T1; flashback table t1 to before drop; √;flashback database to timestamp(sysdate-1/1465); X
本文部落格
本文部落格
http://blog.sina.com.cn/s/blog_bba8a5b40101bdhu.html
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28602568/viewspace-758923/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 閃回表、閃回查詢
- 閃回查詢之閃回表查詢
- (f)--閃回恢復區---實踐3---閃回查詢(基於AUM (auto undo managemet))
- Oracle -- 閃回恢復區---實踐1---閃回庫Oracle
- 基本閃回查詢和閃回表
- 【閃回特性之閃回查詢】使用閃回查詢(select as of)
- 閃回(關於閃回查詢)
- 閃回刪除、閃回查詢
- oralce恢復誤刪除的表中的資料(閃回、閃回查詢)
- 閃回查詢之閃回版本查詢
- 【備份恢復】閃回技術之閃回版本查詢
- 閃回技術一:閃回查詢
- DM7閃回與閃回查詢
- 閃回查詢恢復誤刪資料
- 閃回查詢
- Oracle閃回恢復區Oracle
- 閃回查詢恢復過程
- 閃回技術二:閃回表
- 閃回(關於閃回資料庫)資料庫
- [閃回特性之閃回版本查詢]Flashback Version Query
- Oracle閃回查詢,閃回版本查詢與閃回事務查詢的使用區別總結Oracle
- 【備份恢復】閃回資料庫(一)閃回資料庫的管理資料庫
- oracle閃回查詢Oracle
- 閃回查詢(轉)
- 閃回查詢(1)
- oracle 閃回查詢Oracle
- 【備份恢復】 閃回技術之閃回刪除
- Oracle 11G 閃回技術 閃回版本查詢和閃回事務查詢Oracle
- Oracle閃回技術之閃回資料庫Oracle資料庫
- 【備份恢復】閃回資料庫(五)RMAN 命令列閃回資料庫資料庫命令列
- 【備份恢復】閃回資料庫(二) 基於 SCN 閃回資料庫資料庫
- Oracle閃回查詢恢復delete刪除資料Oracledelete
- Oracle資料庫的閃回恢復區Oracle資料庫
- 閃回版本查詢與閃回事務查詢
- 閃回技術查詢資料
- Oracle 11G 閃回技術 使用Oracle閃回查詢Oracle
- Oracle 11G 閃回技術 使用閃回版本查詢Oracle
- Oracle10g閃回恢復區詳解--開啟,設定閃回區Oracle