Oracle恢复truncate删除表的数据
SQL> show parameter flashback
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_flashback_retention_target integer 1440
flashback功能默认为1440分钟,也就一天时间
数据库闪回状态可以从v$database视图中查询
SQL> select dbid,name,flashback_on,current_scn from v$database;
DBID NAME FLASHBACK_ON CURRENT_SCN
---------- --------- ------------------ -----------
2274326636 RISENET NO 997660
flashback_on为NO,也就是没有开flashback功能,当truncate删除数据时,无法使用flashback
启动flashback_on(需要数据库在mount状态下打开)
SQL> shutdown immediate;
数据库已经关闭。
已经卸载数据库。
ORACLE 例程已经关闭。
SQL> startup mount
ORACLE 例程已经启动。
Total System Global Area 272629760 bytes
Fixed Size 1248476 bytes
Variable Size 109052708 bytes
Database Buffers 155189248 bytes
Redo Buffers 7139328 bytes
数据库装载完毕。
SQL> alter database flashback on;
数据库已更改。
SQL> select dbid,name,flashback_on,current_scn from v$database;
DBID NAME FLASHBACK_ON CURRENT_SCN
---------- --------- ------------------ -----------
2274326636 RISENET YES 0
SQL> alter database open;
数据库已更改。
SQL> connect scott/mzl
已连接。
SQL> select table_name from user_tables;