0
点赞
收藏
分享

微信扫一扫

11G Oracle的二种恢复单表的方法

1kesou 2022-05-18 阅读 67

今天应用人员说9点20分左右程序误删了数据,需要对表进行恢复。

很久没有做过恢复了。如果不用rman,有2种方法进行恢复。

对于本次是11G.11G的RMAN 无法进行单表恢复。

  1. 通过flushback进行恢复
  2. 在原有表上进行恢复
方案一、
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');



举报

相关推荐

0 条评论