数据库update后的数据恢复

在开发过程中,我们有时候不注意,写的脚本漏了where 条件或者因其他原因,导致数据更新错误,在没有执行install语句前,可以根据时间点将数据恢复还原。

查询修改的数据

select cert_cd from crm as of timestamp to_timestamp('2019-10-22 16:30:46','yyyy-mm-dd hh24:mi:ss');

1、修改还原单个字段的数据

update crm t1 set t1.cert = (select cert from crm as of timestamp to_timestamp('2019-10-22 16:30:46','yyyy-mm-dd hh24:mi:ss') where t1.sn = sn);

2、修改还原整个表数据

-- 查询删除的表数据
select * from 表名 as of timestamp to_timestamp('删除时间点','yyyy-mm-dd hh24:mi:ss')

-- 把删除的数据重新插入原表:
 insert into 表名 (select * from 表名 as of timestamp to_timestamp('删除时间点','yyyy-mm-dd hh24:mi:ss'));
-- 注意要保证主键不重复。

-- 例如:
insert into TEST (select * from TEST as of timestamp to_timestamp('2020-01-16 17:30:46','yyyy-mm-dd hh24:mi:ss'));

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

dreaming317

你的鼓励将是我创作的最大动力!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值