ORACLE 10G中閃回彙總
1、檢視當前SCN並且轉換為時間
select scn_to_timestamp(dbms_flashback.get_system_change_number) from dual;
select timestamp_to_scn(to_date('2013-08-2 10:01:00','yyyy-mm-dd hh24:mi:ss')) from dual;
2、開啟和使用flashback database
--必須開啟歸檔
--必須設定引數
db_flashback_retention_target
db_recovery_file_dest
db_recovery_file_dest_size --如果查過快速恢復區大小,FLASHBACK LOG會自動刪除
--mount節點設定開啟FLASHBACK DATABASE ON
alter database flashback on;
可以從v$FLASHBACK_DATABASE_LOG檢視中獲得OLDEST_FLASHBACK_SCN或者OLDEST_FLASHBACK_TIME,以確定FLASHBACK DATABASE能夠恢復到最早的時刻。
然後mount,RMAN下執行
flashback database to scn=689316;
flashback database to time="04-9月-2008 11:05:00";
最後open resetlogs
如果檢視恢復可恢復SCN以前的就會報錯
starting media recovery
media recovery failed
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of flashback command at 08/02/2013 09:03:28
ORA-38729: Not enough flashback database log data to do FLASHBACK.
3、閃回表(flashback table)
FLASHBACK TABLE
ALTER TABLE TEST enable row movement;
flashback table TEST to timestamp SYSDATE-1;
flashback table pp123 to timestamp (to_date('2013-08-2 10:01:00','yyyy-mm-dd hh24:mi:ss'));
flashback table pp123 to scn **
4、閃回drop的表(flashback drop)
--引數recyclebin 設定為on(預設)
--依賴於recyclebin
flashback table test_re to before drop; --索引會隨著一起DROP到recyclebin
alter index "BIN$4u6QyIlxGzzgQAB/AQAl8Q==$0" rename to test; --重命令你的索引
flashback table "BIN$4u6QyIl7GzzgQAB/AQAl8Q==$0" to before drop;--如果有同名需要這樣恢復
select * from "BIN$4u6QyImDGzzgQAB/AQAl8Q==$0";--你可以檢視回收站
drop table test_re purge;--你可以手動避開回收站
purge user_recyclebin;--清理本OWNER下回收站
purge dba_recyclebin;--清理所有OWNER的回收站需要sysdba.
5、閃回查詢
SELECT * FROM test
AS OF TIMESTAMP TO_TIMESTAMP
('2013-08-04 10:22:00', 'yyyy-mm-dd hh24:mi:ss') ;
6、FLASHBACK VERISON(注意UPDATE,DELETE會生成2行如下)
SELECT versions_startscn,
versions_starttime,
versions_endscn,
versions_endtime,
versions_xid,
versions_operation,
username
FROM testll VERSIONS BETWEEN TIMESTAMP (to_date('2013-08-2 23:34:07','yyyy-mm-dd hh24:mi:ss')) AND sysdate
where versions_startscn is not null or versions_endscn is not null;
VERSIONS_STARTSCN VERSIONS_STARTTIME VERSIONS_ENDSCN VERSIONS_ENDTIME VERSIONS_XID VERSIONS_OPERATION USERNAME
----------------- -------------------------------------------------------------------------------- --------------- -------------------------------------------------------------------------------- ---------------- ------------------ ------------------------------
33860567 02-AUG-13 11.41.51 PM 0D001300311D0000 U ooo
33860342 02-AUG-13 11.36.17 PM 0E0027002F1D0000 D SYSTEM
33860309 02-AUG-13 11.35.07 PM 0D001200311D0000 D SYS
33860309 02-AUG-13 11.35.07 PM SYS
33860342 02-AUG-13 11.36.17 PM SYSTEM
33860567 02-AUG-13 11.41.51 PM PPZHU
VERSIONS_STARTSCN VERSIONS_STARTTIME VERSIONS_ENDSCN VERSIONS_ENDTIME VERSIONS_XID VERSIONS_OPERATION USERNAME
----------------- -------------------------------------------------------------------------------- --------------- -------------------------------------------------------------------------------- ---------------- ------------------ ------------------------------
33861435 03-AUG-13 12.02.00 AM 0F000000321D0000 I SYS
7、閃回事務(可以找到回退語句,但是查詢相當慢,使用不當會影響生產系統效能))
SELECT xid, operation, start_scn,commit_scn, logon_user, undo_sql
FROM flashback_transaction_query WHERE xid = HEXTORAW('000200030000002D');
SELECT xid, logon_user FROM flashback_transaction_query
WHERE xid IN (SELECT versions_xid FROM employees VERSIONS BETWEEN TIMESTAMP
TO_TIMESTAMP('2003-07-18 14:00:00', 'YYYY-MM-DD HH24:MI:SS') AND
TO_TIMESTAMP('2003-07-18 17:00:00', 'YYYY-MM-DD HH24:MI:SS'));
select scn_to_timestamp(dbms_flashback.get_system_change_number) from dual;
select timestamp_to_scn(to_date('2013-08-2 10:01:00','yyyy-mm-dd hh24:mi:ss')) from dual;
2、開啟和使用flashback database
--必須開啟歸檔
--必須設定引數
db_flashback_retention_target
db_recovery_file_dest
db_recovery_file_dest_size --如果查過快速恢復區大小,FLASHBACK LOG會自動刪除
--mount節點設定開啟FLASHBACK DATABASE ON
alter database flashback on;
可以從v$FLASHBACK_DATABASE_LOG檢視中獲得OLDEST_FLASHBACK_SCN或者OLDEST_FLASHBACK_TIME,以確定FLASHBACK DATABASE能夠恢復到最早的時刻。
然後mount,RMAN下執行
flashback database to scn=689316;
flashback database to time="04-9月-2008 11:05:00";
最後open resetlogs
如果檢視恢復可恢復SCN以前的就會報錯
starting media recovery
media recovery failed
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of flashback command at 08/02/2013 09:03:28
ORA-38729: Not enough flashback database log data to do FLASHBACK.
3、閃回表(flashback table)
FLASHBACK TABLE
ALTER TABLE TEST enable row movement;
flashback table TEST to timestamp SYSDATE-1;
flashback table pp123 to timestamp (to_date('2013-08-2 10:01:00','yyyy-mm-dd hh24:mi:ss'));
flashback table pp123 to scn **
4、閃回drop的表(flashback drop)
--引數recyclebin 設定為on(預設)
--依賴於recyclebin
flashback table test_re to before drop; --索引會隨著一起DROP到recyclebin
alter index "BIN$4u6QyIlxGzzgQAB/AQAl8Q==$0" rename to test; --重命令你的索引
flashback table "BIN$4u6QyIl7GzzgQAB/AQAl8Q==$0" to before drop;--如果有同名需要這樣恢復
select * from "BIN$4u6QyImDGzzgQAB/AQAl8Q==$0";--你可以檢視回收站
drop table test_re purge;--你可以手動避開回收站
purge user_recyclebin;--清理本OWNER下回收站
purge dba_recyclebin;--清理所有OWNER的回收站需要sysdba.
5、閃回查詢
SELECT * FROM test
AS OF TIMESTAMP TO_TIMESTAMP
('2013-08-04 10:22:00', 'yyyy-mm-dd hh24:mi:ss') ;
6、FLASHBACK VERISON(注意UPDATE,DELETE會生成2行如下)
SELECT versions_startscn,
versions_starttime,
versions_endscn,
versions_endtime,
versions_xid,
versions_operation,
username
FROM testll VERSIONS BETWEEN TIMESTAMP (to_date('2013-08-2 23:34:07','yyyy-mm-dd hh24:mi:ss')) AND sysdate
where versions_startscn is not null or versions_endscn is not null;
VERSIONS_STARTSCN VERSIONS_STARTTIME VERSIONS_ENDSCN VERSIONS_ENDTIME VERSIONS_XID VERSIONS_OPERATION USERNAME
----------------- -------------------------------------------------------------------------------- --------------- -------------------------------------------------------------------------------- ---------------- ------------------ ------------------------------
33860567 02-AUG-13 11.41.51 PM 0D001300311D0000 U ooo
33860342 02-AUG-13 11.36.17 PM 0E0027002F1D0000 D SYSTEM
33860309 02-AUG-13 11.35.07 PM 0D001200311D0000 D SYS
33860309 02-AUG-13 11.35.07 PM SYS
33860342 02-AUG-13 11.36.17 PM SYSTEM
33860567 02-AUG-13 11.41.51 PM PPZHU
VERSIONS_STARTSCN VERSIONS_STARTTIME VERSIONS_ENDSCN VERSIONS_ENDTIME VERSIONS_XID VERSIONS_OPERATION USERNAME
----------------- -------------------------------------------------------------------------------- --------------- -------------------------------------------------------------------------------- ---------------- ------------------ ------------------------------
33861435 03-AUG-13 12.02.00 AM 0F000000321D0000 I SYS
7、閃回事務(可以找到回退語句,但是查詢相當慢,使用不當會影響生產系統效能))
SELECT xid, operation, start_scn,commit_scn, logon_user, undo_sql
FROM flashback_transaction_query WHERE xid = HEXTORAW('000200030000002D');
SELECT xid, logon_user FROM flashback_transaction_query
WHERE xid IN (SELECT versions_xid FROM employees VERSIONS BETWEEN TIMESTAMP
TO_TIMESTAMP('2003-07-18 14:00:00', 'YYYY-MM-DD HH24:MI:SS') AND
TO_TIMESTAMP('2003-07-18 17:00:00', 'YYYY-MM-DD HH24:MI:SS'));
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/7728585/viewspace-1308969/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 10g閃回總結
- 使用 Oracle Database 10g中的閃回表特性OracleDatabase
- Oracle 10G 新特性——閃回表Oracle 10g
- Oracle Database 10g新特性-閃回表OracleDatabase
- Oracle 10g的閃回查詢概述Oracle 10g
- oracle閃回Oracle
- oracle 閃回Oracle
- Oracle Database 10g新特性-閃回版本查詢OracleDatabase
- Oracle9i,.10g 閃回查詢(flashback)Oracle
- oracle 閃回 flashbackOracle
- oracle閃回特性Oracle
- Oracle閃回技術 為Oracle閃回配置資料庫Oracle資料庫
- 【聽海日誌】之Oracle 10g閃回資料庫Oracle 10g資料庫
- Oracle閃回查詢,閃回版本查詢與閃回事務查詢的使用區別總結Oracle
- Oracle閃回技術之閃回資料庫Oracle資料庫
- oralce 10g閃回學習(一)
- Oracle 11G 閃回技術 使用Oracle閃回查詢Oracle
- oracle閃回查詢Oracle
- Oracle閃回刪除Oracle
- Oracle閃回詳解Oracle
- 清空 oracle 閃回區Oracle
- Oracle 之 閃回操作Oracle
- oracle 閃回查詢Oracle
- 教你如何成為Oracle 10g OCP - 第十四章 閃回Oracle 10g
- 10g新特性——閃回版本查詢
- Red Hat 6.5安裝Oracle 10g故障彙總Oracle 10g
- 關於oracle閃回資料歸檔的總結Oracle
- FlashBack總結之閃回資料庫與閃回刪除資料庫
- Oracle 閃回技術 概覽 資料庫閃回功能Oracle資料庫
- Oracle -- 閃回恢復區---實踐1---閃回庫Oracle
- Oracle Flashback 閃回查詢功能操作範例(9i and 10g)Oracle
- Oracle資料庫閃回Oracle資料庫
- Oracle閃回資料庫Oracle資料庫
- Oracle閃回恢復區Oracle
- oracle的閃回查詢Oracle
- oracle的回閃查詢Oracle
- Oracle 閃回特性(FLASHBACK DATABASE)OracleDatabase
- oracle 9i 閃回Oracle