我正在使用Greenplum DB 4.3版本,一个包含我的应用程序的元数据信息的表,它被错误地删除了,
有没有办法回滚一个被错误删除的表?
答案 0 :(得分:0)
如果您使用drop table <tablename>
,那么没有什么可以帮助 - 表文件在您提交后从文件系统中删除
如果您使用了delete from <tablename>
,那么您仍然可以访问此数据。您需要设置GUC set gp_select_invisible=on
- 这样您就可以查看所有已删除的数据。您需要使用字段xmax来查找您的交易删除的数据,我的文章简要介绍了它的工作原理:http://0x0fff.com/mvcc-in-transactional-systems/
答案 1 :(得分:0)
在上述情况下我也被困一次
如果您在param下面更新
,也可以检查已删除的数据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','user1@ril.com');
insert into smpl values(103,'user3','user3','user3@ril.com');
insert into smpl values(102,'user2','user2','user2@ril.com');
--Check if data is properly inserted
select *,xmin,xmax,cmin,cmax from smpl
(对于新插入的数据,xmax = 0)
--delete all data
delete from smpl
(删除数据的xmax&lt;&gt; 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','user11@ril.com');
insert into smpl values(103,'user3','user3','user13@ril.com');
(用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
谢谢