Oracle闪回
数据库 2
-- oracle数据删除恢复
select id,authority from SYS_GROUP as of timestamp to_timestamp('2019-08-19 16:30:00','yyyy-mm-dd hh24:mi:ss');
alter table SYS_GROUP enable row movement;
flashback table SYS_GROUP to  timestamp to_timestamp('2019-08-19 16:30:00','yyyy-mm-dd hh24:mi:ss');
-- 创建表
create table Test (
	id varchar2(64) primary key,
	name VARCHAR2(100)
);
-- 插入数据
INSERT INTO Test values ('1', '张三');
INSERT INTO Test values ('2', '李四');
INSERT INTO Test values ('3', '王五');
INSERT INTO Test values ('4', '赵六');
-- 现在是17:02 等待一分钟
-- 现在是17:03 删除数据
DELETE FROM Test;
-- 查询17:02是有数据的
select * from Test as of timestamp to_timestamp('2019-08-19 17:02:00','yyyy-mm-dd hh24:mi:ss');
-- 还原数据
INSERT INTO Test SELECT * FROM Test as of timestamp to_timestamp('2019-08-19 17:02:00','yyyy-mm-dd hh24:mi:ss');
-- 数据还原成功 如果是部分字段误删
UPDATE Test SET name = '';
UPDATE Test t1 SET t1.name =  (select name from Test as of timestamp to_timestamp('2019-08-19 17:02:00','yyyy-mm-dd hh24:mi:ss') where id = T1.id);
Oracle闪回
http://blog.sunafei.top/archives/1729235133702
作者
sunafei
发布于
更新于
许可