Oracle备份数据
--备份入库数据 drop table SYS_KEEPACCOUNT_HX_bak; delete * from SYS_KEEPACCOUNT_HX_bak; create table SYS_KEEPACCOUNT_HX_bak as (select * from SYS_KEEPACCOUNT_HX where cdate = to_date('2020-12-02','yyyy-MM-dd')); commit; --查询备份入库数据 select * from SYS_KEEPACCOUNT_HX_bak; select count(1) from SYS_KEEPACCOUNT_HX_bak; --删除入库的数据 delete from SYS_KEEPACCOUNT_HX where cdate = to_date('2020-12-02','yyyy-MM-dd'); commit; select s_sys_keepaccount_hx.nextval from dual --还原入库数据 INSERT INTO SYS_KEEPACCOUNT_HX (seqid,FIELD1, FIELD2, FIELD3, FIELD4, FIELD5) select s_sys_keepaccount_hx.nextval, FIELD1, FIELD2, FIELD3, FIELD4, FIELD5 from SYS_KEEPACCOUNT_HX_bak,dual where cdate = to_date('2020-12-02','yyyy-MM-dd'); commit;
orcal回滚操作
查询某个时间点的数据,如果只是少量数据被修改,我们可以直接用查询出来的历史数据来update表
SELECT * FROM 表名 as of TIMESTAMP "TO_TIMESTAMP"('2018-05-29 17:58:00', 'yyyy-MM-dd HH24:mi:ss') WHERE 条件 ;
恢复某个时间点的数据
--开启行移动功能(解决执行以下语句报错问题) alter table Dxc_Goods enable row movement; --恢复某个时间点的数据 flashback table Dxc_Goods to timestamp to_timestamp('2019-07-24 18:00:00','yyyy-mm-dd hh24:mi:ss'); --关闭行移动功能 alter table Dxc_Goods disable row movement;