前提:数据库处于归档模式,闪回功能打开
SQL> select name,flashback_on from v$database;
NAME FLASHBACK_ON
--------- ------------------
PROD YES
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /database/arch
Oldest online log sequence 0
Next log sequence to archive 1
Current log sequence 1
测试环境准备:
SQL> select count(1) from emp_test;
COUNT(1)
----------
14
SQL> select current_scn from v$database;
CURRENT_SCN
-----------
512679
SQL> truncate table emp_test;
SQL> select count(1) from emp_test;
COUNT(1)
----------
0
使用闪回数据库恢复被truncate掉的数据
1)SQL> startup mount;
2)SQL> flashback database to scn 512679;
3)以read only方式开库,确实数据是否已经找回
SQL> alter database open read only;
4)查看emp_test表,truncate掉的数据已经找回
SQL> select count(1) from emp_test;
COUNT(1)
----------
14
SQL> select name,flashback_on from v$database;
NAME FLASHBACK_ON
--------- ------------------
PROD YES
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /database/arch
Oldest online log sequence 0
Next log sequence to archive 1
Current log sequence 1
测试环境准备:
SQL> select count(1) from emp_test;
COUNT(1)
----------
14
SQL> select current_scn from v$database;
CURRENT_SCN
-----------
512679
SQL> truncate table emp_test;
SQL> select count(1) from emp_test;
COUNT(1)
----------
0
使用闪回数据库恢复被truncate掉的数据
1)SQL> startup mount;
2)SQL> flashback database to scn 512679;
3)以read only方式开库,确实数据是否已经找回
SQL> alter database open read only;
4)查看emp_test表,truncate掉的数据已经找回
SQL> select count(1) from emp_test;
COUNT(1)
----------
14
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29424472/viewspace-1255471/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/29424472/viewspace-1255471/