【Oracle】使用bbed手动提交事务
有时候数据库挂掉,起库会出现ORA-00704错误,而导致ORA-00704错误的根本原因是訪问OBJ$的时候。ORACLE须要回滚段中的数据,而訪问回滚段的时候须要的undo数据已经被覆盖,此时我们能够通过bbed工具手工提交事务。从而解决问题。
使用bbed提交事务測试步骤例如以下:
JP@ORCL>create table JP_BBED_TEST as select * from hr.employees where rownum<=10;
Table created.
JP@ORCL>select rowid, dbms_rowid.rowid_relative_fno(rowid)rel_fno,
dbms_rowid.rowid_block_number(rowid)blockno,
dbms_rowid.rowid_row_number(rowid) rowno
from jp_bbed_test; 2 3 4
ROWID REL_FNO BLOCKNO ROWNO
------------------ ---------- ---------- ----------
AAAM7wAAEAAAAGcAAA 4 412 0
AAAM7wAAEAAAAGcAAB 4 412 1
AAAM7wAAEAAAAGcAAC 4 412 2
AAAM7wAAEAAAAGcAAD 4 412 3
AAAM7wAAEAAAAGcAAE 4 412 4
AAAM7wAAEAAAAGcAAF 4 412 5
AAAM7wAAEAAAAGcAAG 4 412 6
AAAM7wAAEAAAAGcAAH 4 412 7
AAAM7wAAEAAAAGcAAI 4 412 8
AAAM7wAAEAAAAGcAAJ 4 412 9
10 rows selected.
JP@ORCL>select last_name from jp_bbed_test;
LAST_NAME
-------------------------
OConnell
Grant
Whalen
Hartstein
Fay
Mavris
Baer
Higgins
Gietz
King
10 rows selected.
JP@ORCL>update jp_bbed_test set LAST_NAME='BADLY9';
10 rows updated.
此时事务没有提交,其它的session是无法查看此时的改动的。
另开一个窗体
[oracle@jp bbed]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Fri Jun 6 06:56:52 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SYS@ORCL>alter system checkpoint;
System altered.
SYS@ORCL>alter system dump datafile 4 block 412;
System altered.
SYS@ORCL>oradebug setmypid
Statement processed.
SYS@ORCL>oradebug tracefile_name
/u01/app/oracle/admin/ORCL/udump/orcl_ora_17715.trc
查看/u01/app/oracle/admin/ORCL/udump/orcl_ora_17715.trc文件
我们能够看到下面内容:
Block header dump: 0x0100019c
Object id on Block?
Y
seg/obj: 0xcef0 csc: 0x00.c3cf8 itc: 3 flg: E typ: 1 - DATA
brn: 0 bdba: 0x1000199 ver: 0x01 opc: 0
inc: 0 exflg: 0
Itl Xid Uba Flag Lck Scn/Fsc
0x01 0xffff.000.00000000 0x00000000.0000.00 C--- 0 scn 0x0000.000c3cf8
0x02 0x0006.02b.000001a1 0x008000d0.00f6.2a ---- 10 fsc 0x0000.00000000
0x03 0x0000.000.00000000 0x00000000.0000.00 ---- 0 fsc 0x0000.00000000
这里能够看到我们LCK了10条表中记录
这时候我们使用bbed将事务提交:
首先使用session2 flush buffer_pool。假设不清空buffer pool。再次读取该block时将不会进行物理读,无法看到改动后的结果并且会覆盖我们的改动:
SYS@ORCL>alter system flush buffer_cache;
System altered.
使用bbed工具进行改动:
BBED> set dba 4,412
DBA 0x0100019c (16777628 4,412)
BBED> map
File: /u01/app/oracle/oradata/ORCL/users01.dbf (4)
Block: 412 Dba:0x0100019c
------------------------------------------------------------
KTB Data Block (Table/Cluster)
struct kcbh, 20 bytes @0
struct ktbbh, 96 bytes @20
struct kdbh, 14 bytes @124
struct kdbt[1], 4 bytes @138
sb2 kdbr[10] @142
ub1 freespace[6794] @162
ub1 rowdata[1232] @6956
ub4 tailchk @8188
BBED> p ktbbh
struct ktbbh, 96 bytes @20
ub1 ktbbhtyp @20 0x01 (KDDBTDATA)
union ktbbhsid, 4 bytes @24
ub4 ktbbhsg1 @24 0x0000cef0
ub4 ktbbhod1 @24 0x0000cef0
struct ktbbhcsc, 8 bytes @28
ub4 kscnbas @28 0x000c3cf8
ub2 kscnwrp @32 0x0000
b2 ktbbhict @36 3
ub1 ktbbhflg @38 0x32 (NONE)
ub1 ktbbhfsl @39 0x00
ub4 ktbbhfnx @40 0x01000199
struct ktbbhitl[0], 24 bytes @44
struct ktbitxid, 8 bytes @44
ub2 kxidusn @44 0xffff
ub2 kxidslt @46 0x0000
ub4 kxidsqn @48 0x00000000
struct ktbituba, 8 bytes @52
ub4 kubadba @52 0x00000000
ub2 kubaseq @56 0x0000
ub1 kubarec @58 0x00
ub2 ktbitflg @60 0x8000 (KTBFCOM)
union _ktbitun, 2 bytes @62
b2 _ktbitfsc @62 0
ub2 _ktbitwrp @62 0x0000
ub4 ktbitbas @64 0x000c3cf8
struct ktbbhitl[1], 24 bytes @68
struct ktbitxid, 8 bytes @68
ub2 kxidusn @68 0x0006
ub2 kxidslt @70 0x002b
ub4 kxidsqn @72 0x000001a1
struct ktbituba, 8 bytes @76
ub4 kubadba @76 0x008000d0
ub2 kubaseq @80 0x00f6
ub1 kubarec @82 0x2a
ub2 ktbitflg @84 0x000a (NONE)
union _ktbitun, 2 bytes @86
b2 _ktbitfsc @86 0
ub2 _ktbitwrp @86 0x0000
ub4 ktbitbas @88 0x00000000
struct ktbbhitl[2], 24 bytes @92
struct ktbitxid, 8 bytes @92
ub2 kxidusn @92 0x0000
ub2 kxidslt @94 0x0000
ub4 kxidsqn @96 0x00000000
struct ktbituba, 8 bytes @100
ub4 kubadba @100 0x00000000
ub2 kubaseq @104 0x0000
ub1 kubarec @106 0x00
ub2 ktbitflg @108 0x0000 (NONE)
union _ktbitun, 2 bytes @110
b2 _ktbitfsc @110 0
ub2 _ktbitwrp @110 0x0000
ub4 ktbitbas @112 0x00000000
关于事务的状态例如以下:
TRANSACTION_COMMITED = 0×08;
TRANSACTION_UPBOUND = 0×02;
TRANSACTION_ACTIVE = 0×01;
BBED> m /x 0080 offset 84
File: /u01/app/oracle/oradata/ORCL/users01.dbf (4)
Block: 412 Offsets: 84 to 595 Dba:0x0100019c
------------------------------------------------------------------------
00800000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00010a00 ffff2600 b01aac1c ac1c0000 0a008e1c 481cac1e
021cc41b e51d811b 391bf01a b01a0000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
<32 bytes per line>
BBED> p ktbbh
struct ktbbh, 96 bytes @20
ub1 ktbbhtyp @20 0x01 (KDDBTDATA)
union ktbbhsid, 4 bytes @24
ub4 ktbbhsg1 @24 0x0000cef0
ub4 ktbbhod1 @24 0x0000cef0
struct ktbbhcsc, 8 bytes @28
ub4 kscnbas @28 0x000c3cf8
ub2 kscnwrp @32 0x0000
b2 ktbbhict @36 3
ub1 ktbbhflg @38 0x32 (NONE)
ub1 ktbbhfsl @39 0x00
ub4 ktbbhfnx @40 0x01000199
struct ktbbhitl[0], 24 bytes @44
struct ktbitxid, 8 bytes @44
ub2 kxidusn @44 0xffff
ub2 kxidslt @46 0x0000
ub4 kxidsqn @48 0x00000000
struct ktbituba, 8 bytes @52
ub4 kubadba @52 0x00000000
ub2 kubaseq @56 0x0000
ub1 kubarec @58 0x00
ub2 ktbitflg @60 0x8000 (KTBFCOM)
union _ktbitun, 2 bytes @62
b2 _ktbitfsc @62 0
ub2 _ktbitwrp @62 0x0000
ub4 ktbitbas @64 0x000c3cf8
struct ktbbhitl[1], 24 bytes @68
struct ktbitxid, 8 bytes @68
ub2 kxidusn @68 0x0006
ub2 kxidslt @70 0x002b
ub4 kxidsqn @72 0x000001a1
struct ktbituba, 8 bytes @76
ub4 kubadba @76 0x008000d0
ub2 kubaseq @80 0x00f6
ub1 kubarec @82 0x2a
ub2 ktbitflg @84 0x8000 (KTBFCOM)
union _ktbitun, 2 bytes @86
b2 _ktbitfsc @86 0
ub2 _ktbitwrp @86 0x0000
ub4 ktbitbas @88 0x00000000
struct ktbbhitl[2], 24 bytes @92
struct ktbitxid, 8 bytes @92
ub2 kxidusn @92 0x0000
ub2 kxidslt @94 0x0000
ub4 kxidsqn @96 0x00000000
struct ktbituba, 8 bytes @100
ub4 kubadba @100 0x00000000
ub2 kubaseq @104 0x0000
ub1 kubarec @106 0x00
ub2 ktbitflg @108 0x0000 (NONE)
union _ktbitun, 2 bytes @110
b2 _ktbitfsc @110 0
ub2 _ktbitwrp @110 0x0000
ub4 ktbitbas @112 0x00000000
BBED> sum apply
Check value for File 4, Block 412:
current = 0x14cc, required = 0x14cc
BBED> exit
这时候重开一个session查看该表信息:
SYS@ORCL>select last_name from jp.jp_bbed_test;
LAST_NAME
-------------------------
BADLY9
BADLY9
BADLY9
BADLY9
BADLY9
BADLY9
BADLY9
BADLY9
BADLY9
BADLY9
10 rows selected.
尽管session1的事务没有提交但此时其它session已经能够查看该改动结果。
有时改动完ktbitflg之后其它session仍然不能查看改动结果,此时使用bbed将ub2 _ktbitwrp改动为0就可以查看到改动后的结果。
须要注意的是假设此时session 1仍然能够将该事务进行回滚。
Session 1:
JP@ORCL>rollback;
Rollback complete.
Session 3:
JP@ORCL>select last_name from jp_bbed_test;
LAST_NAME
-------------------------
OConnell
Grant
Whalen
Hartstein
Fay
Mavris
Baer
Higgins
Gietz
King
10 rows selected.
【Oracle】使用bbed手动提交事务的更多相关文章
- Spring 手动 提交事务
1.配置文件 applicationContext.xml: <bean id="txManager"class="org.springframework.jdbc ...
- Spring 手动提交事务
在使用Spring声明式事务时,不需要手动的开启事务和关闭事务,但是对于一些场景则需要开发人员手动的提交事务,比如说一个操作中需要处理大量的数据库更改,可以将大量的数据库更改分批的提交,又比如一次事务 ...
- Java中手动提交事务
项目中遇到一个问题,就是在程序的执行过程中需要不断地更新某个信息,但是在springmvc中好像是默认不可以的,那么就需要手动提交 // 从spring容器对象中获取DataSourceTransac ...
- mysql中,手动提交事务
1: 在mysql中,手动提交事务的案例:CREATE PROCEDURE tfer_funds (from_account int, to_account int, tfer_amoun ...
- Oracle 11g R2手动配置EM(转)
转自:http://blog.itpub.net/9034054/viewspace-1973418/ Oracle 11g R2手动配置EM Oracle 作者:luashin 时间:2016-01 ...
- ORACLE数据恢复方法(提交事务也可以)
今天在操作数据库的时候,发现数据操作错误,想要恢复,但是没有用事务,按理说,设置成不默认提交事务,此时所做的各种操作都没有反应到数据库中.这时,你可以rollback事务,撤销所有未提交的修改.不过, ...
- Oracle 10g 数据库手动创建步骤
Oracle 数据库手动创建步骤 编写初始化参数文件 设置操作系统环境变量 创建实例 以管理员身份连接数据库 启动实例 create database 创建数据库 运行数据字典脚本 Oracle的网络 ...
- Oracle 判断 并 手动收集 统计信息 脚本
CREATE OR REPLACE PROCEDURE SchameB.PRC_GATHER_STATS AUTHID CURRENT_USER IS BEGIN SYS.DBMS_STATS.GAT ...
- springboot 开启事务以及手动提交事务
添加依赖,sprongboot 会默认开启事务管理 org.springframework.boot spring-boot-starter-jdbc 在需要的服务类里添加注解 @Autowired ...
随机推荐
- Failed to read schema document 'http://code.alibabatech.com/schema/dubbo/dubbo.xsd'问题解决方法
Failed to read schema document 'http://code.alibabatech.com/schema/dubbo/dubbo.xsd'问题解决方法 关于dubbo服务的 ...
- 安卓开发笔记——丰富多彩的TextView
随手笔记,记录一些东西~ 记得之前写过一篇文章<安卓开发笔记——个性化TextView(新浪微博)>:http://www.cnblogs.com/lichenwei/p/4411607. ...
- 设计模式-结构型模式,python桥接模式
桥接模式 桥接(Bridge)是用于把抽象化与实现化解耦,使得二者可以独立变化.这种类型的设计模式属于结构型模式,它通过提供抽象化和实现化之间的桥接结构,来实现二者的解耦. 这种模式涉及到一个作为桥接 ...
- [Full-stack] 状态管理技巧 - Redux
资源一: In React JS Tutorials, lectures from 9. From: React高级篇(一)从Flux到Redux,react-redux 从Flux到Redux,再到 ...
- PDF to image
http://www.verypdf.com/pdf2tif/pdf-to-image/help.htm http://www.softinterface.com/DL/DL_Alternate_Do ...
- day_6.22python多线程
僵尸进程:子进程结束,父类未结束 孤儿进程:父类进程over.,子进程未结束 0号进程负责运行,1号进程负责生成,所有孤儿进程的收容所(孤儿进程:父类进程over)1号进程,永不结束! Linux: ...
- 整合Solr与tomcat以及第一个core的配置
整合Solr与tomcat以及第一个core的配置 一.准备安装文件 Tomcat : apache-tomcat-8.5.32.tar.gz Solr:solr-5.3.1.tgz 二.创建目录并解 ...
- windows对象 document对象 的一些操作 9.23
函数: 四要素 1.返回类型2.函数名3.参数列表4.函数体 window . 对象 opener 打开当前窗口的源窗口 alert(window.opener); open( ) 例子: ...
- winform excel导入--自带office.interop.excel方式
用npoi方式,遇到一个问题,有的excel用加密软件(盖章,只读等)生成的解析不了,所以换成自带的方式,可以解决. 需要引用系统自带Microsoft.office.interop.excel pu ...
- 使用double无法得到数学上的精确结果的原因及为何不能用double来初始化BigDecimal
使用double无法得到数学上的精确结果的原因: double类型的数值占用64bit,即64个二进制数,除去最高位表示正负符号的位,在最低位上一定会与实际数据存在误差(除非实际数据恰好是2的n次方) ...