Search code examples
db2db2-luwlocks

How to determine the applications and application id holding locks on a certain table


I know the command for table holding locks.Can anyone give the command to determine application and application id holding locks for the certain table.

Thanks in advance


Solution

  • You can use the monitor function MON_GET_LOCKS(), for example

    SELECT lock_name, 
           member, 
           lock_status,
           application_handle 
    FROM 
        TABLE (MON_GET_LOCKS(NULL, -2))
    

    You can then use MON_GET_CONNECTION() to retrieve application details by its handle and MON_FORMAT_LOCK_NAME() to obtain detailed information about a particular lock.