当前位置:Gxlcms > mysql > Oracleundo镜像数据探究

Oracleundo镜像数据探究

时间:2021-07-01 10:21:17 帮助过:42人阅读

undo是为了保证一致性读的,也就是说你在对更改的数据但是没有提交,那么其他session是无法查看到你更改的内容的,如果对方 进行

我们都知道,undo是为了保证一致性读的,也就是说你在对更改的数据但是没有提交,那么其他session是无法查看到你更改的内容的,如果对方 进行读取数据,依然是之前的数据,undo就是保存了数据的前镜像。看完我写的这篇文章之后,你就知道undo是怎么保存前镜像的以及它的内部机 制是什么。现在开始挖掘undo是怎么保存前镜像的。

推荐阅读:

[Oracle] 在没有备份的情况下undo损坏怎么办?

UNDO表空间失败的处理方法

undo表空间故障和ORA-01548处理

RAC下丢失undo表空间的恢复

UNDO表空间备份恢复

1)首先更新一条数据,但是不进行commit如下:
SQL> col name for a50
SQL> select obj#,name from t where rownum<5;

OBJ# NAME
---------- --------------------------------------------------
46 I_USER1
28 Rhys1
15 RHYS20
29 RHYS3

SQL> update t set where obj#=46;

1 row updated.

SQL> update t set where obj#=28;

1 row updated.

SQL> update t set where obj#=15;

1 row updated.

SQL> update t set where obj#=29;

1 row updated.

SQL> select xidusn,xidslot,ubafil,ubablk from v$transaction;

XIDUSN XIDSLOT UBAFIL UBABLK
---------- ---------- ---------- ----------
12 7 8 1493

SQL> select * from v$rollname where usn=12;

USN NAME
---------- ------------------------------
12 _SYSSMU12_584745277$

SQL> select usn,status,curext from v$rollstat;

USN STATUS CUREXT
---------- --------------- ----------
0 ONLINE 5
11 ONLINE 4
12 ONLINE 3
13 ONLINE 2
14 ONLINE 3
15 ONLINE 2
16 ONLINE 2
17 ONLINE 14
18 ONLINE 4
19 ONLINE 3
20 ONLINE 2

11 rows selected.

SQL> select usn,status,curext,xacts from v$rollstat where xacts>0;

USN STATUS CUREXT XACTS
---------- --------------- ---------- ----------
12 ONLINE 3 1

SQL> alter system dump undo header '_SYSSMU12_584745277$';

System altered.

SQL> alter system dump datafile 8 block 1493;

System altered.

SQL> col name for a80
SQL> col inst_id for 9999
SQL> col value for a80
SQL> select * from v$diag_info;

INST_ID NAME VALUE
------- -------------------------------------------------------------------------------- --------------------------------------------------------------------------------
1 Diag Enabled TRUE
1 ADR Base /opt/app/oracle
1 ADR Home /opt/app/oracle/diag/rdbms/rhys/RHYS
1 Diag Trace /opt/app/oracle/diag/rdbms/rhys/RHYS/trace
1 Diag Alert /opt/app/oracle/diag/rdbms/rhys/RHYS/alert
1 Diag Incident /opt/app/oracle/diag/rdbms/rhys/RHYS/incident
1 Diag Cdump /opt/app/oracle/diag/rdbms/rhys/RHYS/cdump
1 Health Monitor /opt/app/oracle/diag/rdbms/rhys/RHYS/hm
1 Default Trace File /opt/app/oracle/diag/rdbms/rhys/RHYS/trace/RHYS_ora_5284.trc
1 Active Problem Count 1
1 Active Incident Count 1

人气教程排行