Determining which programs are holding locks on an object

You can use the DISPLAY DATABASE command to determine which programs are holding locks on an object.

Procedure

Begin general-use programming interface information.To determine which application programs currently hold locks on the database or space:

Issue the DISPLAY DATABASE command.

Example

For example, issue a command that names table space TSPART in database DB01:

-DISPLAY DATABASE(DB01) SPACENAM(TSPART) LOCKS

Db2 returns a list similar to this one:

17:45:42 DSNT360I - ****************************************************
17:45:42 DSNT361I - *  DISPLAY DATABASE SUMMARY
17:45:42            *    GLOBAL LOCKS
17:45:42 DSNT360I - ****************************************************
17:45:42 DSNT362I -     DATABASE = DB01  STATUS = RW
17:45:42                DBD LENGTH = yyyy
17:45:42 DSNT397I -
 NAME     TYPE PART  STATUS            CONNID   CORRID       LOCKINFO
 -------- ---- ----- ----------------- -------- ------------ ---------

 TSPART   TS    0001 RW                LSS001   DSN2SQL      H-IX,P,C
 TSPART   TS    0002 RW                LSS001   DSN2SQL      H-IX,P,C
 TSPART   TS    0003 RW                LSS001   DSN2SQL      H-IX,P,C
 TSPART   TS    0004 RW                LSS001   DSN2SQL      H-IX,P,C
 ******* DISPLAY OF DATABASE DB01     ENDED      **********************
 17:45:44 DSN9022I . DSNTDDIS 'DISPLAY DATABASE' NORMAL COMPLETION

Use the LOCKS ONLY keywords on the DISPLAY DATABASE command to display only spaces that have locks. You can substitute the LOCKS keyword with USE, CLAIMERS, LPL, or WEPR to display only databases that fit the criteria. Use DISPLAY DATABASE as follows:

-DISPLAY DATABASE (DSNDB06) SPACENAM(*) LOCKS ONLY

This command results in the following messages:

11:44:32 DSNT360I - ****************************************************
11:44:32 DSNT361I - *  DISPLAY DATABASE SUMMARY
11:44:32            *      GLOBAL LOCKS
11:44:32 DSNT360I - ****************************************************
11:44:32 DSNT362I -     DATABASE = DSNDB06   STATUS = RW
                           DBD LENGTH = 60560
11:44:32 DSNT397I -
NAME     TYPE PART  STATUS            CONNID   CORRID       LOCKINFO
-------- ---- ----- ----------------- -------- ------------ ---------

SYSTSTSP TS         RW                DSN      020.DBCMD 06 H-IS,P,C
******* DISPLAY OF DATABASE DSNDB06  ENDED      **********************
11:45:15 DSN9022I - DSNTDDIS 'DISPLAY DATABASE' NORMAL COMPLETION

End general-use programming interface information.