oracle闪回功能
闪回表中的数据
–必须打开行移动功能alter table ccc_log enable row movement;
SELECT * FROM ccc_log
delete FROM ccc_log
select * from ccc_log
select * from ccc_log as of scn 945256--查询过去时间段表中的数据(以scn号为准)
select * from ccc_log as of timestamp to_timestamp('2020-08-13 01:40:12','yyyy-mm-dd hh24:mi:ss') --查询过去时间段表中的数据(以时间为基准)
flashback table ccc_log to timestamp to_timestamp('2020-08-13 01:40:12','yyyy-mm-dd hh24:mi:ss');--闪回表中的数据
闪回drop掉的表
–前提是打开回收站,show parameter recyclebin查看回收站是否打开
drop table ccc_log
select object_name,original_name,operation,type,droptime from user_recyclebin;
select * from "BIN$rLqttKhXEZzgU2QBEKx2/g==$0"
flashback table ccc_log to before drop;
select * from ccc_log
闪回数据库
–前提是打开数据库归档以及闪回功能
archive log list;--查看是否为归档。如果不是归档模式则需要打开归档模式。
shutdown immediate;
startup mount;
alter database archivelog;
alter database open;
archive log list;
select flashback_on from v$database--查看闪回功能是否打开,以下是打开数据库闪回功能
shutdown immediate;
startup mount;
alter database flashback on;
alter database open;
select flashback_on from v$database;
进行数据库闪回
SELECT * FROM ccc_log
select current_scn from v$database; --1028000
TRUNCATE TABLE ccc_log
SELECT * FROM ccc_log
shutdown immediate; --首先关闭数据库
startup mount; --启动到mount状态;
flashback database to scn 1028900; --闪回操作
alter database open resetlogs; --open数据库,以resetlogs的方式open