误删表或记录
误删除一个表
1,SQL> drop table test1;
Table dropped.
2,查看recyclebin的信息
SQL> col origninal_name format a15;
SQL> col type format a15;
SQL> select object_name,original_name,type from user_recyclebin;
OBJECT_NAME ORIGINAL_NAME TYPE
------------------------------ -------------------------------- -------
BIN$fR5G/49+SZ2oESrTX4UCHg==$0 IDX_TESTID INDEX
BIN$x1Ey4hTFSeilywuQ7KKM+w==$0 TEST1 TABLE
SQL> show recyclebin; --注意这是sqlplus的命令
ORIGINAL NAME RECYCLEBIN
NAME
OBJECT TYPE DROP TIME
---------------- ------------------------------ ------------ -------------------
TEST1 BIN$x1Ey4hTFSeilywuQ7KKM+w==$0 TABLE 2012-01-13:16:35:24
3,将删除的表闪回
SQL> flashback table test1 to before drop;
Flashback complete.
如果多次删除,那么可以直接通过时间字段来查找到误删除的表,然后闪回。
还可以把表闪回后重新命名
flashback table order to before drop rename to order_old_version
误删除表中记录
闪回查询
--闪回到15分钟前
select * from orders as of timestamp (systimestamp - interval '15' minute)
这里可以使用DAY、SECOND、MONTH替换minute,例如:
SELECT * FROM orders AS OF TIMESTAMP(SYSTIMESTAMP - INTERVAL '2' DAY)
--闪回到某个时间点
select * from orders as of timestamp to_timestamp ('01-Sep-04 16:18:57.845993', 'DD-Mon-RR HH24:MI:SS.FF')
--闪回到两天前
select * from orders as of timestamp (sysdate - 2)
闪回一张表到某个时间点
必须条件
Sql >alter table order enable row movement;
到15分钟前:
flashback table order to timestamp systimestamp - interval '15' minute;
到某个时间点:
FLASHBACK TABLE order TO TIMESTAMP TO_TIMESTAMP('2007-09-12 01:15:25 PM','YYYY-MM-DD HH:MI:SS AM')