闪回,读的是undo表空间
======================闪回日志===================================
SQL> show parameter undo
NAME TYPE VALUE
------------------------------------ ---------------------- ------------------------------
undo_management string AUTO
undo_retention integer 900
undo_tablespace string UNDOTBS1
SQL>
SQL> select log_mode from v$database;
LOG_MODE
------------------------
NOARCHIVELOG
SQL> archive log list
Database log mode No Archive Mode //数据日志模式
Automatic archival Disabled
Archive destination USE_DB_RECOVERY_FILE_DEST //归档终点
Oldest online log sequence 47
Current log sequence 49
SQL> alter database flashback on
2 ;
alter database flashback on
*
ERROR at line 1:
ORA-38706: Cannot turn on FLASHBACK DATABASE logging.
ORA-38707: Media recovery is not enabled.
SQL> alter database archivelog;
alter database archivelog
*
ERROR at line 1:
ORA-01126: database must be mounted in this instance and not open in any instance
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 2388570112 bytes
Fixed Size 2255472 bytes
Variable Size 1023411600 bytes
Database Buffers 1342177280 bytes
Redo Buffers 20725760 bytes
Database mounted.
SQL> alter database archivelog;
Database altered.
SQL> select open_mode from v$database;
OPEN_MODE
----------------------------------------
MOUNTED
SQL> alter database flashback on;
Database altered.
SQL> select dbms_flashback.get_system_change_number from dual;
GET_SYSTEM_CHANGE_NUMBER
------------------------
815135
SQL> select to_char(systimestamp,'yyyy-mm-dd HH24:MI:SS') as sysdt from dual;
SYSDT
--------------------------------------
2017-07-25 12:35:42
SQL> truncate table test;
Table truncated.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 2388570112 bytes
Fixed Size 2255472 bytes
Variable Size 1023411600 bytes
Database Buffers 1342177280 bytes
Redo Buffers 20725760 bytes
Database mounted.
SQL> flashback database to scn 815135 //闪回数据库
2 ;
Flashback complete.
SQL> alter database open read only;
Database altered.
SQL> select * from test;
ID
--------------------
4
7
100
900
5
1000
1100
7 rows selected.