如何恢复Oracle delete的数据

create table person(
id varchar2(32),
username varchar2(34),
age number
)

<p>--插入数据<br>
insert into person values('1','张三'23);<br>
insert into person values('2','李四'25)</p>

--有时候我们为了方便处理Oracle的垃圾数据会使用delete语句进行数的删除
delete from person where id='2'
--但是有时候会删错数据,这是需要进行数据的恢复了,以下是数据的恢复的语句

--(1)使用时间戳的办法进行恢复<br>
insert into person(<br>
&nbsp; &nbsp; &nbsp; &nbsp;select * from person<br>
&nbsp; &nbsp; &nbsp; &nbsp;as of timestamp to_timestamp('2019.03.05 10:54:23','yyyy.mm.dd hh24:mi:ss')<br>
&nbsp; &nbsp; &nbsp; &nbsp;where id='2'<br>
)<br>

–注意:表中的主键不能有冲突

--(2)使用表闪回的方法
--注意表闪回要求用户必须要有flash any table权限
 --1,开启行移动功能 
 alter table person enable row movement
 --2,恢复表数据
 flashback table person to timestamp to_timestamp('2019.03.05 11:04:00','yyyy.mm.dd hh24:mi:ss')
--3,关闭行移动功能 
 alter table person disable row movement

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值