今天应用人员说9点20分左右程序误删了数据,需要对表进行恢复。
很久没有做过恢复了。如果不用rman,有2种方法进行恢复。
对于本次是11G.11G的RMAN 无法进行单表恢复。
通过flushback进行恢复
在原有表上进行恢复
方案一、
SQL> alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
Session altered.
SQL> select sysdate from dual;
SYSDATE
-------------------
2022-05-18 11:47:17
SQL> delete table maxx.test_emp;
delete table maxx.test_emp
*
ERROR at line 1:
ORA-00903: invalid table name
SQL> delete from maxx.test_emp;
86355 rows deleted.
SQL> commit;
Commit complete.
SQL> select count(*) from maxx.test_emp AS OF TIMESTAMP TO_TIMESTAMP('2022-05-18 11:47:17', 'YYYY-MM-DD HH24:MI:SS') ;
COUNT(*)
----------
86355
SQL> select count(*) from maxx.test_emp;
COUNT(*)
----------
0
SQL> flashback table maxx.test_emp to timestamp to_timestamp('2022-05-18 11:47:17', 'yyyy-mm-dd hh24:mi:ss');
flashback table maxx.test_emp to timestamp to_timestamp('2022-05-18 11:47:17', 'yyyy-mm-dd hh24:mi:ss')
*
ERROR at line 1:
ORA-08189: cannot flashback the table because row movement is not enabled
SQL> alter table maxx.test_emp enable row movement;
Table altered.
SQL> flashback table maxx.test_emp to timestamp to_timestamp('2022-05-18 11:47:17', 'yyyy-mm-dd hh24:mi:ss');
Flashback complete.
SQL> select count(*) from maxx.test_emp;
COUNT(*)
----------
86355
SQL>
方案二、
select * from maxx.test_emp AS OF TIMESTAMP TO_TIMESTAMP('2022-05-18 00:00:42', 'YYYY-MM-DD HH24:MI:SS');
create table maxx.test_emp_bak20220518 as select * from maxx.test_emp AS OF TIMESTAMP TO_TIMESTAMP('2022-05-18 00:00:42', 'YYYY-MM-DD HH24:MI:SS');
版权声明:本文内容来自51CTO:李石岩;遵循CC 4.0 BY-SA版权协议上原文接及本声明。
本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行可。
原文链接:https://blog.51cto.com/lishiyan/5305265
如有涉及到侵权,请联系,将立即予以删除处理。
在此特别鸣谢原作者的创作。
此篇文章的所有版权归原作者所有,与本公众号无关,商业转载建议请联系原作者,非商业转载请注明出处。