如何在PostgreSQL中回滚更新 [英] How to rollback an update in PostgreSQL

查看:1848
本文介绍了如何在PostgreSQL中回滚更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在终端中使用sql编辑PostgreSQL数据库中的某些记录时(在ubuntu lucid中),我进行了错误的更新。

While editing some records in my PostgreSQL database using sql in the terminal (in ubuntu lucid), I made a wrong update.

而不是-

update mytable set start_time='13:06:00' where id=123;

我输入-

update mytable set start_time='13:06:00';

因此,所有记录现在都具有相同的start_time值。

So, all records are now having the same start_time value.

是否可以撤消此更改?表中有大约500多个记录,我不知道每条记录的start_time值是什么

Is there a way to undo this change? There are some 500+ records in the table, and I do not know what the start_time value for each record was

它会永远丢失吗?

推荐答案

我假设这是已经提交的事务?如果是这样,那就是提交的意思,您将无法返回。

I'm assuming it was a transaction that's already committed? If so, that's what "commit" means, you can't go back.

如果幸运的话,某些数据可以恢复。立即停止数据库。

Some data may be recoverable if you're lucky. Stop the database NOW.

这是我之前针对同一主题写的一个答案。我希望它会有所帮助。

Here's an answer I wrote on the same topic earlier. I hope it's helpful.

这可能也是:在postgresql中删除已删除的行

除非数据绝对关键,仅从备份中还原,否则会容易得多,也不会那么痛苦。如果您没有备份,请考虑一下自己。

Unless the data is absolutely critical, just restore from backups, it'll be lots easier and less painful. If you didn't have backups, consider yourself soundly thwacked.

这篇关于如何在PostgreSQL中回滚更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆