Viewing locks

To get a report on the locks currently being held on Adaptive Server, use sp_lock:

sp_lock
fid spid loid locktype         table_id   page  row dbname   context
--- ---- ---- ---------------- ---------- ----- --- -------- ----------------
  0  15   30  Ex_intent         208003772     0   0 sales    Fam dur
  0  15   30  Ex_page           208003772  2400   0 sales    Fam dur, Ind pg
  0  15   30  Ex_page           208003772  2404   0 sales    Fam dur, Ind pg
  0  15   30  Ex_page-blk       208003772   946   0 sales    Fam dur
  0  30   60  Ex_intent         208003772     0   0 sales    Fam dur
  0  30   60  Ex_page           208003772   997   0 sales    Fam dur
  0  30   60  Ex_page           208003772  2405   0 sales    Fam dur, Ind pg
  0  30   60  Ex_page           208003772  2406   0 sales    Fam dur, Ind pg
  0  35   70  Sh_intent          16003088     0   0 sales    Fam dur
  0  35   70  Sh_page            16003088  1096   0 sales    Fam dur, Inf key
  0  35   70  Sh_page            16003088  3102   0 sales    Fam dur, Range
  0  35   70  Sh_page            16003088  3113   0 sales    Fam dur, Range
  0  35   70  Sh_page            16003088  3365   0 sales    Fam dur, Range
  0  35   70  Sh_page            16003088  3604   0 sales    Fam dur, Range
  0  49   98  Sh_intent         464004684     0   0 master   Fam dur
  0  50  100  Ex_intent         176003658     0   0 stock    Fam dur
  0  50  100  Ex_row            176003658 36773   8 stock    Fam dur
  0  50  100  Ex_intent         208003772     0   0 stock    Fam dur
  0  50  100  Ex_row            208003772 70483   1 stock    Fam dur
  0  50  100  Ex_row            208003772 70483   2 stock    Fam dur
  0  50  100  Ex_row            208003772 70483   3 stock    Fam dur
  0  50  100  Ex_row            208003772 70483   5 stock    Fam dur
  0  50  100  Ex_row            208003772 70483   8 stock    Fam dur
  0  50  100  Ex_row            208003772 70483   9 stock    Fam dur
 32  13   64  Sh_page           240003886 17264   0 stock
 32  16   64  Sh_page           240003886  4376   0 stock
 32  17   64  Sh_page           240003886  7207   0 stock
 32  18   64  Sh_page           240003886 12766   0 stock
 32  18   64  Sh_page           240003886 12767   0 stock
 32  18   64  Sh_page           240003886 12808   0 stock
 32  19   64  Sh_page           240003886 22367   0 stock
 32  32   64  Sh_intent          16003088     0   0 stock    Fam dur
 32  32   64  Sh_intent          48003202     0   0 stock    Fam dur
 32  32   64  Sh_intent          80003316     0   0 stock    Fam dur
 32  32   64  Sh_intent         112003430     0   0 stock    Fam dur
 32  32   64  Sh_intent         176003658     0   0 stock    Fam dur
 32  32   64  Sh_intent         208003772     0   0 stock    Fam dur
 32  32   64  Sh_intent         240003886     0   0 stock    Fam dur

This example shows the lock status of serial processes and two parallel processes:

The lock type column indicates not only whether the lock is a shared lock (“Sh” prefix), an exclusive lock (“Ex” prefix), or an “Update” lock, but also whether it is held on a table (“table” or “intent”) or on a “page” or “row.”

A “demand” suffix indicates that the process will acquire an exclusive lock as soon as all current shared locks are released.

See the System Administration Guide for more information on demand locks.

The context column consists of one or more of the following values:

To see lock information about a particular login, give the spid for the process:

sp_lock 30

fid spid loid locktype         table_id   page  row dbname   context
--- ---- ---- ---------------- ---------- ----- --- -------- ----------------
  0  30   60  Ex_intent         208003772     0   0 sales    Fam dur
  0  30   60  Ex_page           208003772   997   0 sales    Fam dur
  0  30   60  Ex_page           208003772  2405   0 sales    Fam dur, Ind pg
  0  30   60  Ex_page           208003772  2406   0 sales    Fam dur, Ind pg

If the spid you specify is also the fid for a family of processes, sp_who prints information for all of the processes.

You can also request information about locks on two spids:

sp_lock 30, 15
fid spid loid locktype         table_id   page  row dbname   context
--- ---- ---- ---------------- ---------- ----- --- -------- ----------------
  0  15   30  Ex_intent         208003772     0   0 sales    Fam dur
  0  15   30  Ex_page           208003772  2400   0 sales    Fam dur, Ind pg
  0  15   30  Ex_page           208003772  2404   0 sales    Fam dur, Ind pg
  0  15   30  Ex_page-blk       208003772   946   0 sales    Fam dur
  0  30   60  Ex_intent         208003772     0   0 sales    Fam dur
  0  30   60  Ex_page           208003772   997   0 sales    Fam dur
  0  30   60  Ex_page           208003772  2405   0 sales    Fam dur, Ind pg
  0  30   60  Ex_page           208003772  2406   0 sales    Fam dur, Ind pg