闪回功能
闪回查询
1.修改postgresql.conf,添加参数”max_flashback_time=60”开启闪回功能,并重启数据库
2.闪回查询15秒以前的表数据,使用vsql客户端工具执行以下命令:
CREATE TABLE t_person (id bigint, name varchar2(20)); INSERT INTO t_person VALUES (1,'bob'); INSERT INTO t_person VALUES (2,'tim'); SELECT * FROM t_person; DELETE FROM t_person WHERE ID = 2; SELECT pg_sleep(10); SELECT * FROM t_person; SELECT * FROM t_person flashback(15); SELECT * FROM t_person;
闪回表
对数据表的操作进行回退,使用vsql客户端工具执行以下命令:
TRUNCATE TABLE t_person; INSERT INTO t_person VALUES (1,'bob'); INSERT INTO t_person VALUES (2,'tim'); INSERT INTO t_person VALUES (3,'kiki'); SELECT * FROM t_person; SELECT pg_sleep(10); DELETE FROM t_person WHERE id = 3; SELECT * FROM t_person; SELECT pg_flashback('public.t_person',15); SELECT * FROM t_person;