各位DBA,看到这篇文章是不是很开心,解决了你一个大麻烦,赶紧把它部署到实时监控程序吧

(咳咳,转载,抄袭不注明文章出处的人可耻哈)

session 1: update emp_bak set ename='沙雕' where empno=7369;

session 2: update emp_bak set ename='大长腿' where empno=7369;

session 3: update emp_bak set ename='矮丑穷' where empno=7369;

运行下面脚本可以抓到哪个SID,哪个SQL_ID,跑的SQL_TEXT锁住了哪个SID,哪个SQL_ID,哪个SQL语句

需要注意的是:如果V$SQLAREA没有保存SQL,可能抓不到,其次,如果系统并发很高,你可能需要再修改下脚本

select sysdate,source_sid,source_sql_id,source_sql_text,blocking_sid,blocking_sql_id,blocking_sql_textfrom (select b.sid source_sid,d.sql_id source_sql_id,d.sql_text source_sql_text,a.sid blocking_sid,a.sql_id blocking_sql_id,e.sql_text blocking_sql_text,(select object_namefrom dba_objectswhere object_id = a.row_wait_obj#) object_namefrom v$session     a,v$session     b,v$transaction c,v$sqlarea     d,v$sqlarea     ewhere a.event = 'enq: TX - row lock contention'and a.blocking_session = b.sidand b.taddr = c.addrand to_date(c.start_time, 'mm/dd/yy hh24:mi:ss') =d.last_active_time---and d.command_type in (2, 3, 6)and b.user# = d.parsing_schema_idand a.sql_id = e.sql_id)where instr(upper(source_sql_text), object_name) > 0;

脚本运行示例:

SQL> select sysdate,2         source_sid,3         source_sql_id,4         source_sql_text,5         blocking_sid,6         blocking_sql_id,7         blocking_sql_text8    from (select b.sid source_sid,9                 d.sql_id source_sql_id,10                 d.sql_text source_sql_text,11                 a.sid blocking_sid,12                 a.sql_id blocking_sql_id,13                 e.sql_text blocking_sql_text,14                 (select object_name15                    from dba_objects16                   where object_id = a.row_wait_obj#) object_name17            from v$session     a,18                 v$session     b,19                 v$transaction c,20                 v$sqlarea     d,21                 v$sqlarea     e22           where a.event = 'enq: TX - row lock contention'23             and a.blocking_session = b.sid24             and b.taddr = c.addr25             and to_date(c.start_time, 'mm/dd/yy hh24:mi:ss') =26                 d.last_active_time27             ---and d.command_type in (2, 3, 6)28             and b.user# = d.parsing_schema_id29             and a.sql_id = e.sql_id)30   where instr(upper(source_sql_text), object_name) > 0;SYSDATE     SOURCE_SID SOURCE_SQL_ID SOURCE_SQL_TEXT                                  BLOCKING_SID BLOCKING_SQL_ID BLOCKING_SQL_TEXT
----------- ---------- ------------- ------------------------------------------------ ------------ --------------- ------------------------------------------------
2020/5/19 1        192 201c4xcdsjaj0  update emp_bak set ename='沙雕' where empno=7369            4 2hpm4yjuut7cg    update emp_bak set ename='矮丑穷' where empno=73692020/5/19 1        192 201c4xcdsjaj0  update emp_bak set ename='沙雕' where empno=7369          221 36xb1pyv12k56    update emp_bak set ename='大长腿' where empno=7369

Oracle中TX锁(行锁)监控,抓TX锁的源头相关推荐

  1. oracle sqlcode 多条,SQL查询以连接Oracle中多个行的列值

    是否有可能构造SQL来连接列值 多行? 以下是一个示例: 表A PID A B C 表B PID   SEQ    DESC A     1      Have A     2      a nice ...

  2. [转]oracle中查询指定行数的记录

    oracle使用虚列rownum可以查询到指定数字之间的记录数. 第一行的rownum=1 比如我们想查询前五条记录,可以使用 select * from  表名 where rownum<5. ...

  3. oracle中创建函数行变列,oracle decode 函数实现行转列

    用decode函数,或者case when实现行转列 Oracle ----创建测试表create table student_score( name varchar2(20), subject va ...

  4. for oracle中pivot_Oracle PIVOT 行转列方法

    数据库中業種的存储如下图: SELECT * FROM M_TORIHIKISAKI_GYOSYU 其中GYIUSYU_CD字段代表不同的業種 而画面需要实现下图所示样式:(将每条数据的業種横向展开显 ...

  5. easyui一行显示多行_easyui datagrid以及oracle中的多行合并一行

    页面显示: 前端代码: toolbar="#toolbar" rownumbers="true" singleSelect="true" f ...

  6. 面试官问:select......for update会锁表还是锁行?

    欢迎关注方志朋的博客,回复"666"获面试宝典 select查询语句是不会加锁的,但是select .......for update除了有查询的作用外,还会加锁呢,而且它是悲观锁 ...

  7. mysql锁表查询_Mysql upate 更新锁表还是锁行测试

    mysql 学习 主题: -- 查询是否自动提交事务select @@autocommit;--关闭自动提交事务set autocommit = 0;--开启--执行--结束 事务start tran ...

  8. 关于SELECT...FOR UPDATE到底锁表还是锁行

    结论:无论是不是唯一索引,既有表锁也有行锁 不是像网上说的唯一索引锁行,非唯一索引锁表. 非唯一索引:"锁表(不能改)"的原因不是因为表锁的存在,而是行锁(record lock+ ...

  9. select......for update会锁表还是锁行。

    select查询语句是不会加锁的,但是select .......for update除了有查询的作用外,还会加锁呢,而且它是悲观锁. 那么它加的是行锁还是表锁,这就要看是不是用了索引/主键. 没用索 ...

  10. select......for update会锁表还是锁行?

    select查询语句是不会加锁的,但是select .......for update除了有查询的作用外,还会加锁呢,而且它是悲观锁. 那么它加的是行锁还是表锁,这就要看是不是用了索引/主键. 没用索 ...

最新文章

  1. 用Python创建漂亮的交互式可视化效果
  2. mybatis dao实现 || 接口代理方式实现
  3. 【51nod - 前缀异或】 对前缀和的理解
  4. BIC/ImageGP稳定性问题
  5. 第三章 springboot + jedisCluster(转载)
  6. 看完这篇文章还能不懂Flask这种Web框架吗?
  7. 【写作技巧】绪论写作要点
  8. Ipython安装错误集锦
  9. node.js 将jade变为html
  10. Linux学习18-gitlab新建项目提交代码
  11. 戴尔服务器安装linux不能识别硬盘,戴尔服务器重装系统找不到硬盘怎么办.
  12. SEO优化教程之关键词密度及TDK标签布局
  13. sns.relplot
  14. vue项目接入阿里云智能验证
  15. 图片基本处理(imageView2)
  16. shift键计算机功能,分享新手必会的快捷键:shift键的11个妙用!
  17. 新版标准日本语中级_第二十八课
  18. 高桥盾react和boost_React和Boost哪个更好 耐克React和阿迪Boost有什么区别
  19. WOL网络唤醒在微星主板上开启 - ubuntu 20.04
  20. 我在成都火车站捡了个彝族美女 第10节:憋不住的偷窥欲

热门文章

  1. 作为测试人员,你需要掌握哪些,常用软件测试工具?
  2. Linux安装系统注意事项及系统初始化
  3. zabbix客户端日志报错no active checks on server [192.168.3.108:10051]: host [192.168.3.108] not found
  4. ERA5 积雪 降雪 区别_“雪走霾来” 河南降雪今夜停止 19-24日将迎雾霾天
  5. Angular学习总结-跨域配置
  6. 2017年10月13日笔记双边滤波的理解及结合另一篇博客的实现
  7. 计算机二级考试模拟试题及答案,计算机二级考试模拟试题及答案
  8. Embedded software development engineer self-introduction
  9. 液晶屏MIPI接口与LVDS接口区别(总结)
  10. wifi密码忘了?电脑cmd一句搞定