死锁产生的原因:如果有两个会话,每个会话都持有另一个会话想要的资源,此时就会发生死锁。

2张表不同SESSION持有不同记录
SQL> create table t1(id int); Table created. SQL> create table t2(id int); Table created. SQL> select * from t1; ID
----------
1
2 SQL> select * from t2; ID
----------
2
1 开始测试:
SESSION 1:
SQL> select * from v$mystat where rownum<2; SID STATISTIC# VALUE
---------- ---------- ----------
24 0 0 SESSION 2:
SQL> select * from v$mystat where rownum<2; SID STATISTIC# VALUE
---------- ---------- ----------
25 0 0 SESSION 1执行:
SQL> update t1 set id=100 where id=1; 1 row updated. SESSION 2 执行:
SQL> update t2 set id=100 where id=1; 1 row updated. SESSION 1 继续执行:
SQL> update t2 set id=100 where id=1; 此时SESSION 1 HANG SESSION 2继续执行:
SQL> update t1 set id=100 where id=1; 此时SESSION 1出现:
SQL> update t2 set id=100 where id=1;
update t2 set id=100 where id=1
*
ERROR at line 1:
ORA-00060: deadlock detected while waiting for resource -------------------------------------------------------------------- SESSION 1执行:
SQL> update t1 set id=100 where id=1; 1 row updated. SQL> update t2 set id=100 where id=1;
update t2 set id=100 where id=1
*
ERROR at line 1:
ORA-00060: deadlock detected while waiting for resource SESSION 2 执行:
SQL> update t2 set id=100 where id=1; 1 row updated. SQL> update t1 set id=100 where id=1; 查看trace日志:
session 25:
sid: 25 ser: 16 audsid: 1450028 user: 91/TEST flags: 0x45
pid: 23 O/S info: user: oracle, term: UNKNOWN, ospid: 5732
image: oracle@june (TNS V1-V3)
client details:
O/S info: user: oracle, term: pts/3, ospid: 5731
machine: june program: sqlplus@june (TNS V1-V3)
application name: SQL*Plus, hash value=3669949024
current SQL:
update t1 set id=100 where id=1 ----- End of information for the OTHER waiting sessions ----- Information for THIS session: ----- Current SQL Statement for this session (sql_id=75ag6bf3qxyh7) -----
update t2 set id=100 where id=1

修改2张表不同SESSION相互持有记录引发的死锁的更多相关文章

  1. 同一张表不同SESSION相互持有对方记录引发的死锁

    锁产生的原因:如果有两个会话,每个会话都持有另一个会话想要的资源,此时就会发生死锁. 同一张表不同SESSION持有不同记录 SQL> create table t1(id int); Tabl ...

  2. 多个DbContext修改同一张表测试

    多个DbContext修改同一张表经测试是可行的. UserStore和DepartmentStore都可以向SysLog表写入数据 用多个线程同时通过UserStore和DepartmentStor ...

  3. 利用pymysql同时修改两张表的数据

    使用pymysql操作数据库中相关联的两张表需求:两张表中分别有一个字段是json格式,需要往json中再插入一个属性值’container_cloud’=’fasle’. import pymysq ...

  4. sql 查出一张表中重复的所有记录数据

    1.在面试的时候碰到一个 问题,就是让写一张表中有id和name 两个字段,查询出name重复的所有数据,现在列下: select * from xi a where (a.username) in ...

  5. 从远程oracle上导入到本地同一张表中不存在的记录的方法

    场景:在远程oracle上存在一张表A,在本地同样存在一张相同表结构的表B.由于本地表B中保存了业务系统操作产生的几条记录,同时原来导入了A中的部分记录,但是并没有保存A中全部的记录.A中有15条记录 ...

  6. 【SqlServer】【问题收集】删除同一张表中完全相同的记录

    1   概述 在Sqlserver中,当通过SqlServer设计器删除同一张表中两条完全相同的记录时,会弹出如下提示: 点击“是” 弹出如下提示,不让删除 2   问题解决 这个问题很简单,用DEL ...

  7. 关于如何修改一张表中所有行与选定字段的同sql多行语句的添加方法

    利用Excel以及word文档进行操作 将表的字段以及数据全部放入Excel表中并保存. 在word表中将写好的sql语句放入文档,利用邮件--选择收件人--使用现有列表--(选择之前做好的Excel ...

  8. [SQL] SQL 查出一张表中重复的所有记录

    在A表中存在一个字段“AccountId”,而且不同记录之间的“AccountId”值有可能会相同,现在就是需要查询出在该表中的各记录之间,“AccountId”值存在重复的项,这里count记录该字 ...

  9. 转 sql 查出一张表中重复的所有记录数据

    select * from DB_PATCH awhere lower(a.db_name) in (select lower(db_name) from DB_PATCH group by lowe ...

随机推荐

  1. jboss 7 as1 日志配置

    原文地址:https://docs.jboss.org/author/display/AS71/Logging+Configuration Overview The overall server lo ...

  2. javascript 高级程序设计(二)-在html中使用javascript

    <script> async 可选 charset 可选 defer 可选 language 已废弃 src 可选 type 可选

  3. css考核点整理(十一)-响应式开发经验,响应式页面的三种核心技术是什么

    响应式开发经验,响应式页面的三种核心技术是什么

  4. clearTimeout(timeoutfunc) 是否有必要执行

    当使用 setTimeout() 方法的时候,是否必须执行 clearTimeout() ? 在 setTimeout() 内的函数执行之前,如果想要阻止执行该方法,是有必要执行 cleartTime ...

  5. CSS3 变形小结

    为原始大小 b:纵向扭曲,0为不变 c :横向扭曲,0不变 d:垂直伸缩量,1为原始大小 e:水平偏移量,0为初始位置 f  :垂直偏移向,0是初始位置 Ø原点 transform-origin() ...

  6. PHP面向对象的基本写法(区别于java)

    <?php /** * 这是一个人的对象 */ class ClassName { public $name; public $age; public $sex; public static $ ...

  7. Adb connect监听指定的主机和端口/Adb监听Visual Studio Emulator for Android模拟器

    语法: adb connect <host>[:<port>] 使用实例: adb connect //如果连接成功则返回 connected to 说明 在使用Visual ...

  8. IOS-textField

    //初始化textfield并设置位置及大小 UITextField *text = [[UITextField alloc]initWithFrame:CGRectMake(20, 20, 130, ...

  9. [转]一个备份MySQL数据库的简单Shell脚本

    本文翻译自 iSystemAdmin 的 <A Simple Shell Script to Backup MySQL Database> Shell脚本是我们写不同类型命令的一种脚本,这 ...

  10. mongo db安装和php,python插件安装

    安装mongodb 1.下载,解压mongodb(下载解压目录为/opt) 在/opt目录下执行命令 wget fastdl.mongodb.org/linux/mongodb-linux-x86_6 ...