实例级别的回滚

SQL> alter system set log_checkpoints_to_alert=TRUE;

系统已更改。

LOG_CHECKPOINTS_TO_ALERT lets you log your checkpoints to the alert file. Doing so is useful for determining whether checkpoints are occurring at the desired frequency

1.    实例级别的回滚(当然也是事务级别)
+++++++Session 1
SQL> select count(*) from test;

  COUNT(*)
----------
   2782688

SQL> delete from test;

已删除2782688行。


+++++++Session 2

Oracle Corporation      SunOS 5.10      Generic Patch   January 2005
-bash-3.2$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on 星期日 8月 24 15:36:35 2014

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


连接到: 
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> show user
USER 为 "SYS"
SQL> shutdown abort;
ORACLE 例程已经关闭。
SQL> startup mount;
ORACLE 例程已经启动。

Total System Global Area 1887350784 bytes
Fixed Size                  2251968 bytes
Variable Size             973079360 bytes
Database Buffers          905969664 bytes
Redo Buffers                6049792 bytes
数据库装载完毕。
SQL> oradebug setmypid
已处理的语句
SQL> oradebug event 10015 trace name context forever,level 10;
已处理的语句
SQL>  alter database open;

数据库已更改。

SQL> oradebug event 10015 trace name context off;
已处理的语句
SQL> oradebug close_trace
已处理的语句
SQL> oradebug tracefile_name
/oracle/app/diag/rdbms/june/june/trace/june_ora_4046.trc


SQL>  select usn,status from v$rollstat order by 1;

       USN STATUS
---------- ---------------
         0 ONLINE
         1 ONLINE
         2 ONLINE
         3 ONLINE
         4 ONLINE
         5 ONLINE
         6 ONLINE
         7 ONLINE
         8 ONLINE
         9 ONLINE
        10 ONLINE

 
Shutting down instance (abort)
License high water mark = 18
USER (ospid: 4017): terminating the instance
Instance terminated by USER, pid = 4017
Sun Aug 24 15:36:44 2014
Instance shutdown complete


Sun Aug 24 15:37:11 2014
Starting ORACLE instance (normal)
LICENSE_MAX_SESSION = 0
LICENSE_SESSIONS_WARNING = 0
Initial number of CPU is 1
Number of processor cores in the system is 1
Number of processor sockets in the system is 1
CELL communication is configured to use 0 interface(s):
CELL IP affinity details:
    NUMA status: non-NUMA system
    cellaffinity.ora status: N/A
CELL communication will use 1 IP group(s):
    Grp 0: 
Picked latch-free SCN scheme 3
Using LOG_ARCHIVE_DEST_1 parameter default value as /oracle/app/product/11.2.0/dbhome_1/dbs/arch
Autotune of undo retention is turned on. 
IMODE=BR
ILAT =249
LICENSE_MAX_USERS = 0
SYS auditing is disabled
Starting up:
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_HOME = /oracle/app/product/11.2.0/dbhome_1
System name:    SunOS
Node name:      solaris
Release:        5.10
Version:        Generic_147148-26
Machine:        i86pc
Using parameter settings in server-side spfile /oracle/app/product/11.2.0/dbhome_1/dbs/spfilejune.ora
System parameters with non-default values:
  processes                = 1500
  sessions                 = 2272
  nls_language             = "SIMPLIFIED CHINESE"
  nls_territory            = "CHINA"
  sga_target               = 1808M
  control_files            = "/oracle/june/control01.ctl"
  control_files            = "/oracle/june/control02.ctl"
  db_block_size            = 8192
  compatible               = "11.2.0.4.0"
  undo_tablespace          = "UNDOTBS1"
  remote_login_passwordfile= "EXCLUSIVE"
  db_domain                = ""
  dispatchers              = "(PROTOCOL=TCP) (SERVICE=juneXDB)"
  audit_file_dest          = "/oracle/app/admin/june/adump"
  audit_trail              = "DB"
  db_name                  = "june"
  open_cursors             = 300
  pga_aggregate_target     = 200M
  diagnostic_dest          = "/oracle/app"
Sun Aug 24 15:37:21 2014
PMON started with pid=2, OS id=4022 
Sun Aug 24 15:37:21 2014
PSP0 started with pid=3, OS id=4023 
Sun Aug 24 15:37:21 2014
VKTM started with pid=4, OS id=4024 at elevated priority
VKTM running at (10)millisec precision with DBRM quantum (100)ms
Sun Aug 24 15:37:21 2014
GEN0 started with pid=5, OS id=4027 
Sun Aug 24 15:37:21 2014
DIAG started with pid=6, OS id=4028 
Sun Aug 24 15:37:21 2014
DBRM started with pid=7, OS id=4029 
Sun Aug 24 15:37:21 2014
DIA0 started with pid=8, OS id=4030 
Sun Aug 24 15:37:21 2014
MMAN started with pid=9, OS id=4031 
Sun Aug 24 15:37:22 2014
DBW0 started with pid=10, OS id=4032 
Sun Aug 24 15:37:22 2014
LGWR started with pid=11, OS id=4033 at elevated priority
Sun Aug 24 15:37:22 2014
CKPT started with pid=12, OS id=4036 
Sun Aug 24 15:37:22 2014
SMON started with pid=13, OS id=4037 
Sun Aug 24 15:37:22 2014
RECO started with pid=14, OS id=4038 
Sun Aug 24 15:37:22 2014
MMON started with pid=15, OS id=4039 
Sun Aug 24 15:37:22 2014
starting up 1 dispatcher(s) for network address '(ADDRESS=(PARTIAL=YES)(PROTOCOL=TCP))'...
Sun Aug 24 15:37:22 2014
MMNL started with pid=16, OS id=4040 
starting up 1 shared server(s) ...
ORACLE_BASE from environment = /oracle/app
Sun Aug 24 15:37:23 2014
ALTER DATABASE   MOUNT
Successful mount of redo thread 1, with mount id 751060083
Database mounted in Exclusive Mode
Lost write protection disabled
Completed: ALTER DATABASE   MOUNT
Sun Aug 24 15:37:46 2014
 alter database open
Beginning crash recovery of 1 threads
Started redo scan
Completed redo scan
 read 82282 KB redo, 9128 data blocks need recovery
Started redo application at
 Thread 1: logseq 36, block 8850
Recovery of Online Redo Log: Thread 1 Group 3 Seq 36 Reading mem 0
  Mem# 0: /oracle/june/redo03.log
Recovery of Online Redo Log: Thread 1 Group 1 Seq 37 Reading mem 0
  Mem# 0: /oracle/june/redo01.log
Completed redo application of 70.26MB
Completed crash recovery at
 Thread 1: logseq 37, block 75407, scn 1057882
 9128 data blocks read, 9128 data blocks written, 82282 redo k-bytes read
Sun Aug 24 15:37:53 2014
Thread 1 advanced to log sequence 38 (thread open)
Thread 1 opened at log sequence 38
  Current log# 2 seq# 38 mem# 0: /oracle/june/redo02.log
Successful open of redo thread 1
MTTR advisory is disabled because FAST_START_MTTR_TARGET is not set
Sun Aug 24 15:37:53 2014
SMON: enabling cache recovery
Sun Aug 24 15:37:56 2014
[4046] Successfully onlined Undo Tablespace 2.
Undo initialization finished serial:0 start:63078044 end:63079818 diff:1774 (17 seconds)
Verifying file header compatibility for 11g tablespace encryption..
Verifying 11g file header compatibility for tablespace encryption completed
SMON: enabling tx recovery
Database Characterset is ZHS16GBK
No Resource Manager plan active
replication_dependency_tracking turned off (no async multimaster replication found)
Starting background process QMNC
Sun Aug 24 15:38:01 2014
QMNC started with pid=21, OS id=4049 
Sun Aug 24 15:38:12 2014
Completed:  alter database open
Sun Aug 24 15:38:21 2014
Starting background process CJQ0
Sun Aug 24 15:38:21 2014
CJQ0 started with pid=25, OS id=4059 
Sun Aug 24 15:38:23 2014
Thread 1 advanced to log sequence 39 (LGWR switch)
  Current log# 3 seq# 39 mem# 0: /oracle/june/redo03.log
Setting Resource Manager plan SCHEDULER[0x32DF]:DEFAULT_MAINTENANCE_PLAN via scheduler window
Setting Resource Manager plan DEFAULT_MAINTENANCE_PLAN via parameter
Sun Aug 24 15:38:25 2014
Starting background process VKRM
Sun Aug 24 15:38:25 2014
VKRM started with pid=24, OS id=4060 
Thread 1 advanced to log sequence 40 (LGWR switch)
  Current log# 1 seq# 40 mem# 0: /oracle/june/redo01.log
Sun Aug 24 15:38:37 2014
Thread 1 cannot allocate new log, sequence 41
Checkpoint not complete
  Current log# 1 seq# 40 mem# 0: /oracle/june/redo01.log
Thread 1 advanced to log sequence 41 (LGWR switch)
  Current log# 2 seq# 41 mem# 0: /oracle/june/redo02.log
Sun Aug 24 15:38:50 2014
Thread 1 cannot allocate new log, sequence 42
Checkpoint not complete
  Current log# 2 seq# 41 mem# 0: /oracle/june/redo02.log
Thread 1 advanced to log sequence 42 (LGWR switch)
  Current log# 3 seq# 42 mem# 0: /oracle/june/redo03.log

前滚用redo完成,在数据库打开之前

回滚是利用Undo,在数据库打开之后

原文地址:https://www.cnblogs.com/hzcya1995/p/13352095.html