• oracle10G锁查询、批量杀锁及常用sql


    前言

    记录1.oracle10G锁查杀技巧 2.资源检查方面的sql

    锁查杀 

    找出所有被锁的对象。注意:不一定是死锁,大部分应该是阻塞,如果发现大量的锁对象,一定要检查程序逻辑了,优化sql
    
    select l.session_id,o.owner,o.object_name
    from v$locked_object l,dba_objects o
    where l.object_id=o.object_id
    批量杀  注意:杀某用户的时候,用另一个用户登录去杀  
    权限:角色权限dba 系统权限 unlimited tablespace
    declare cursor mycur is select b.sid,b.serial#   from v$locked_object a,v$session b   where a.session_id = b.sid group by b.sid,b.serial#; begin for cur in mycur loop execute immediate ( 'alter system kill session '''||cur.sid || ','|| cur.SERIAL# ||''' '); end loop; end;

    查询最占用资源的查询

    磁盘读频率大于100秒的sql
    select b.username username,a.disk_reads reads,
        a.executions exec,a.disk_reads/decode(a.executions,0,1,a.executions) rds_exec_ratio,
        a.sql_text Statement
    from  v$sqlarea a,dba_users b
    where a.parsing_user_id=b.user_id
     and a.disk_reads > 100000   --单位1000=1s
    order by a.disk_reads desc;

    查询完整sql语句

    根据SELECT * FROM v$sqlarea中找到hash_value
    
    然后执行
    SELECT * FROM v$sqltext WHERE hash_value = '&hash_value' ORDER BY piece
    
    即可得到完整的sql语句
  • 相关阅读:
    *args, **kwargs
    python format函数
    python自省
    生成器与迭代器
    python面试题
    xpath和gzip
    python正则表达式
    cookie
    random
    杭电1710 (已知二叉树前中序 求后序)
  • 原文地址:https://www.cnblogs.com/whf191/p/5684418.html
Copyright © 2020-2023  润新知