db2 锁相关信息

---查看SAMPLE库上表的锁数量
SELECT TABSCHEMA, TABNAME, COUNT(*) AS NUMBER_OF_LOCKS_HELD
   FROM SYSIBMADM.LOCKS_HELD
   --WHERE DB_NAME = 'SAMPLE'
   GROUP BY DBPARTITIONNUM, TABSCHEMA, TABNAME

----查询数据库锁表信息
db2 "select agent_id, tabschema,tabname from sysibmadm.snaplock"

----查看锁等待
SELECT SMALLINT(AGENT_ID) AS WAITING_ID,       SUBSTR(APPL_NAME, 1,10) AS WAITING_APP,       SUBSTR(AUTHID,1,10) AS WAITING_USER,       SMALLINT(AGENT_ID_HOLDING_LK) AS HOLDER_ID,       LOCK_MODE AS HELD,        LOCK_OBJECT_TYPE AS TYPE,        LOCK_MODE_REQUESTED AS REQUEST FROM SYSIBMADM.LOCKWAITS

查看锁表信息
-------------
SELECT substr(TABSCHEMA,1,10), substr(TABNAME,1,20), COUNT(*) AS NUMBER_OF_LOCKS_HELD FROM SYSIBMADM.LOCKS_HELD  GROUP BY DBPARTITIONNUM, TABSCHEMA, TABNAME

你可能感兴趣的:(db2)