User locks in Oracle
As we know, we can use dbms_lock package to manage our application locks. For example we can create «lock» for synchronize logic in application or you can «lock» your external resources (file handler, network sockets etc).
You can use different modes for lock your user resource:
- nl -> «NuLl»
- ss -> «Sub Shared»
- sx -> «Sub eXclusive»
- s -> «Shared»
- ssx -> «Shared Sub eXclusive»,
- x -> «eXclusive»
The following table is important to understand difference between lock modes:
If one process «held» lock, and other try to get lock – it get result from this table:

Also you can manage timeout to get lock, if resource locked your process will wait during «timeout».
For example:

The first process create lock to resource, because resource is free. (for example mode S)
Second process try to get lock with short timeout and incompatible lock mode (X) , it return value 1 – TimeOut.
Third process has log timeout and it create new lock after all previous lock was released.
Fourth process create new user lock because it has compatible lock mode. (for example S.
For monitoring user locks you should use:
- dba_lock view (or v$lock),
- DBMS_LOCK_ALLOCATED view
- v$session view
UTLLOCKT.SQL script
documentation:
version: Oracle 9.2


