回滚Greenplum中删除的表数据

问题描述 投票:0回答:3

我正在使用Greenplum DB 4.3版本,一个包含我的应用程序元数据信息的表,但它被错误地删除了,

有什么办法可以回滚误删除的表吗??

database greenplum
3个回答
0
投票

如果您使用

drop table <tablename>
,那么没有任何帮助 - 当您提交表文件时,表文件已从文件系统中删除

如果您使用

delete from <tablename>
那么您仍然可以访问此数据。您需要设置 GUC
set gp_select_invisible=on
- 这将允许您查看所有已删除的数据。您需要使用字段 xmax 来查找被您的交易删除的数据,我的文章简要介绍了它的幕后工作原理:http://0x0fff.com/mvcc-in-transactional-systems/


0
投票

我也曾陷入过上述情况

如果您更新以下参数,您还可以检查已删除的数据

set gp_select_invisible = on 

如果未运行真空则

以下是整个过程

--create a table 

create table smpl 
( userid integer, 
  username character varying(35), 
  password character varying(15), 
  email character varying(60) 
) 

--insert some sample date 

insert into smpl values(101,'user1','user1','[email protected]'); 
insert into smpl values(103,'user3','user3','[email protected]'); 
insert into smpl values(102,'user2','user2','[email protected]'); 

--Check if data is properly inserted 

select *,xmin,xmax,cmin,cmax from smpl 

(对于新插入的数据,xmax = 0)

--delete all data 

delete from smpl 

(xmax <> 0 表示删除的数据)

--if you update below parameter as ON;you can check the deleted data also 

set gp_select_invisible = on 

select *,xmin,xmax,cmin,cmax from smpl 

--vacuum smpl 

(如果你的朗姆酒真空吸尘器删除的数据将会丢失)

--insert some more data with same id 

insert into smpl values(101,'user1','user1','[email protected]'); 

insert into smpl values(103,'user3','user3','[email protected]'); 

(用xmin和xmax再次检查数据)

--if you set it off;you cant check the deleted data 

set gp_select_invisible = off 

select *,xmin,xmax,cmin,cmax from smpl 

谢谢


0
投票

我选择已删除的行。但现在如何恢复呢?

© www.soinside.com 2019 - 2024. All rights reserved.