【问题标题】:Rollback data of a table deleted in GreenplumGreenplum中删除的表的回滚数据
【发布时间】:2015-02-03 07:46:28
【问题描述】:

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

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

【问题讨论】:

  • 如果delete 已提交,您唯一的机会就是恢复备份。

标签: database greenplum


【解决方案1】:

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

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

【讨论】:

    【解决方案2】:

    上述情况我也被困过一次

    你也可以检查删除的数据,如果你在参数下面更新

    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 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 
    

    谢谢

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-04
      • 2019-10-15
      • 1970-01-01
      • 1970-01-01
      • 2023-04-01
      • 2015-08-05
      相关资源
      最近更新 更多