SQL> alter system set db_recovery_file_dest_size=10g; System altered. SQL> alter system set db_recovery_file_dest='/arch'; System altered. SQL> show parameter recover NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ db_recovery_file_dest string /arch db_recovery_file_dest_size big integer 10G db_unrecoverable_scn_tracking boolean TRUE recovery_parallelism integer 0 SQL> select flashback_on from v$database; FLASHBACK_ON ------------------ NO SQL> select force_logging from v$database; FOR --- NO SQL> archive log list; Database log mode No Archive Mode Automatic archival Disabled Archive destination USE_DB_RECOVERY_FILE_DEST Oldest online log sequence 7 Current log sequence 10 SQL> alter system switch logfile; System altered. SQL> alter system checkpoint; System altered. SQL> shu immediate; Database closed. Database dismounted. ORACLE instance shut down. SQL> exit Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options [oracle@dj ~]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.4.0 Production on Wed Oct 31 17:32:11 2018 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to an idle instance. SQL> startup mount; ORACLE instance started. Total System Global Area 985427968 bytes Fixed Size 2259280 bytes Variable Size 859834032 bytes Database Buffers 117440512 bytes Redo Buffers 5894144 bytes Database mounted. SQL> show parameter name NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ cell_offloadgroup_name string db_file_name_convert string db_name string syd db_unique_name string syd global_names boolean FALSE instance_name string syd lock_name_space string log_file_name_convert string processor_group_name string service_names string syd SQL> alter database archivelog; Database altered. SQL> alter database force logging; Database altered. SQL> alter database flashback on; Database altered. SQL> alter database open; Database altered. SQL> show parameter recover NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ db_recovery_file_dest string /arch db_recovery_file_dest_size big integer 10G db_unrecoverable_scn_tracking boolean TRUE recovery_parallelism integer 0 SQL> archive log list Database log mode Archive Mode Automatic archival Enabled Archive destination USE_DB_RECOVERY_FILE_DEST Oldest online log sequence 8 Next log sequence to archive 11 Current log sequence 11 SQL> select flashback_on,force_logging from v$database; FLASHBACK_ON FOR ------------------ --- YES YES SQL> select dbms_flashback.get_system_change_number from dual; GET_SYSTEM_CHANGE_NUMBER ------------------------ 1131503 SQL> conn scott/oracle Connected. SQL> drop table FLASH_TBL; Table dropped. SQL> flashback table scott.FLASH_TBL to before drop; Flashback complete. SQL> select * from flash_tbl; ID VL ---------- -- 10 I 11 J 12 K 13 L 14 M 15 N 16 O 17 P 18 Q 19 R 20 S ID VL ---------- -- 1 / 2 A 3 B 4 C 5 D 6 E 7 F 8 G 9 H 20 rows selected. SQL> drop table FLASH_TBL purge; Table dropped. SQL> flashback table scott.FLASH_TBL to before drop; flashback table scott.FLASH_TBL to before drop * ERROR at line 1: ORA-38305: object not in RECYCLE BIN SQL> conn /as sysdba Connected. SQL> shu immediate Database closed. Database dismounted. ORACLE instance shut down. SQL> exit Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options [oracle@dj ~]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.4.0 Production on Wed Oct 31 17:44:23 2018 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to an idle instance. SQL> startup mount ORACLE instance started. Total System Global Area 985427968 bytes Fixed Size 2259280 bytes Variable Size 859834032 bytes Database Buffers 117440512 bytes Redo Buffers 5894144 bytes Database mounted. SQL> flashback database to scn 1131503; Flashback complete. |
由于实验环境直接resetlogs打开数据库,数据库scn 1131503之后操作的数据将全部丢失,生产环境建议alter database open read only打开数据库,将误操作的数据导出,recover database后再将数据导入。
SQL> alter database open resetlogs; Database altered. SQL> conn scott/oracle Connected. SQL> select * from flash_tbl; ID VL ---------- -- 10 I 11 J 12 K 13 L 14 M 15 N 16 O 17 P 18 Q 19 R 20 S ID VL ---------- -- 1 / 2 A 3 B 4 C 5 D 6 E 7 F 8 G 9 H 20 rows selected. |