Example documentationLOCKS Locate this document in the navigation structure

 

Use of the system table DOMAIN.LOCKS

Prerequisites

You can use the demo data for the SQL tutorial. Start the Database Studio as database administrator MONA with the password RED and log on to demo database DEMODB: Logging On to a Database.

Activities

You can use Database Studio to enter and execute SQL statements. More information: Working with SQL Statements: Overview

Note the General Instructions for formulating SQL statements.

You can use the system table LOCKS to determine the following database information, among other things:

  • All locks that are currently held on table ROOM

    SELECT lockmode, lockstate, rowidlength, rowidhex, rowid

    FROM DOMAIN.LOCKS

    WHERE tablename = 'ROOM'

  • All locks that the current database user holds in that database session on table ROOM

    SELECT lockmode, lockstate, rowidlength, rowidhex, rowid

    FROM DOMAIN.LOCKS, SYSINFO.SESSIONS

    WHERE tablename = 'ROOM'

    AND locks.session = sessions.sessionid

    See also: System Tables, SESSIONS

  • All locks that are currently held on the table with the hexadecimal internal identification 000000000000035D

    SELECT lockmode, lockstate, rowidlength, rowidhex, rowid

    FROM DOMAIN.LOCKS

    WHERE tableid = X'000000000000035D'

If the current database user is the database administrator (DBA user) or the database system administrator, then all currently held locks are shown.

Database users that belong to other user classes only see the locks held by that one database user.