Oracle flashback table实战演练
1.闪回一个table的演练
[oracle@localhost oracle]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Mon Sep 5 09:41:33 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> conn scott/tiger
Connected.
SQL> select * from tab;
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
DEPT TABLE
EMP TABLE
BONUS TABLE
SALGRADE TABLE
MV1 TABLE
T_AUDIT TABLE
TEST_FLASHBACK TABLE
7 rows selected.
SQL> select * from test_flashback;
A
----------
1
1
1
2
3
SQL> drop table test_flashback;
Table dropped.
//如果是sys用户的话可以查看dba_recyclebin视图
SQL> show recyclebin;
ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE DROP TIME
---------------- ------------------------------ ------------ -------------------
TEST_FLASHBACK BIN$rCfQ9MsGEbvgQKEKEVUN6w==$0 TABLE 2011-09-05:09:41:56
SQL> select * from test_flashback;
select * from test_flashback
*
ERROR at line 1:
ORA-00942: table or view does not exist
//闪回
SQL> flashback table test_flashback to before drop;
Flashback complete.
SQL> show recyclebin;
SQL> select * from test_flashback;
A
----------
1
1
1
2
3
//OK,到此闪回一个table完成了。
值得注意的是:闪回Drop table不需要开启闪回功能(在mount下alter database flashback on),因为Drop操作在oracle中只是改名而已,然后放到recyclebin中(逻辑概念)。会永远存在直到当前table所在的tablespace空间不足时,oracle会自动清理已经drop的table。
另外,system表空间下面的table不能闪回,个人认为既然可以drop system下面的table,那肯定是dba才能做的事情,dba是不应该犯错的。
闪回table,table上的index和trriger也跟着回来
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/25694091/viewspace-706723/ ,如需转载,请注明出处,否则将追究法律责任。