huguozhi 发表于 2007-09-20 16:28

写了个查锁表sql的sh

参数是表名
如果是有多个库,自己可加多一个参数库名(dbsname)


环境HPUX+informix 9.4FC6

#cat locksql



#!/bin/ksh
#查锁表的sql
#by huguozhi 20070919

if [ $# -ne 1 ];then
   echo 检查锁表SQL
   echo 用法 $0 表名
   exit 1
fi

onstat - >/dev/null
if [ $? = 255 ] ;then
    echo "没有Online Server !"
    exit 1
fi
t_no=`dbaccess sysmaster<< !
         select count(*) from syslocks where tabname="$1";
!`
l_lkcnt=`echo $t_no|awk '{print $2}'`
if [ $l_lkcnt -eq 0 ];then
   echo "没锁表:"$1"的进程."
   exit 1
else
   s_no=`dbaccess sysmaster<< !
         select max(owner) from syslocks where tabname="$1";
!`
sid=`echo $s_no|awk '{print $2}'`
   echo $1"表被锁进程:"$sid
   onstat -g ses $sid
   onstat -u|grep $sid
fi

[ 本帖最后由 huguozhi 于 2007-9-20 16:29 编辑 ]

liaosnet 发表于 2007-09-20 17:05

原帖由 huguozhi 于 2007-9-20 16:28 发表 http://bbs.chinaunix.net/images/common/back.gif
参数是表名
如果是有多个库,自己可加多一个参数库名(dbsname)


环境HPUX+informix 9.4FC6

#cat locksql



#!/bin/ksh
#查锁表的sql
#by huguozhi 20070919

if [ $# -ne 1 ];then
   echo 检 ...

锁表是很正常的~~~有很多操作都需要进很锁表~~~我们要关注的是锁对性能的影响..
页: [1]
查看完整版本: 写了个查锁表sql的sh