PDA

View Full Version : find what user has a row locked for update??


Guest
05-20-2005, 01:51 PM
Is there a way to find out what user has a lock on a record? I am
performing a lock on a record by doing a for update nowait in my select
statement. I want to get down to the row that is locked in that table.
I have found that I can see what user has a record locked on a table
by executing:
select
oracle_username,
os_user_name,
locked_mode,
object_name,
object_type
from
v$locked_object a,dba_objects b
where
a.object_id = b.object_id;

Is there a way to find out which record that user is locking? Say an
ID field.
Thanks.

Jeff Chirco

K Gopalakrishnan
05-20-2005, 07:07 PM
Jeff:

It would be quite difficult to get the details without block dumps as
the lock information is kept at the data block level and oracle does
not maintain any external record (lock table) for the TX locks. But if
the session is waiting for the row, which is already locked by some
other user, sometimes that information is visible in V$SESSION (FILE#,
BLOCK# and ROW# for ROW_WAITs)

Best Regards,
K Gopalakrishnan
Co-Author: Oracle Wait Interface, Oracle Press 2004
http://www.amazon.com/exec/obidos/tg/detail/-/007222729X/

DA Morgan
05-20-2005, 10:38 PM
jeffchirco@gmail.com wrote: Is there a way to find out what user has a lock on a record? I am performing a lock on a record by doing a for update nowait in my select statement. I want to get down to the row that is locked in that table. I have found that I can see what user has a record locked on a table by executing: select oracle_username, os_user_name, locked_mode, object_name, object_type from v$locked_object a,dba_objects b where a.object_id = b.object_id; Is there a way to find out which record that user is locking? Say an ID field. Thanks. Jeff Chirco

This may not be what you want but look at:

$ORACLE_HOME/rdbms/admin/catblock.sql
Creates views that dynamically display lock dependency graphs

$ORACLE_HOME/rdbms/admin/userlock.sql
Routines that allow the user to request, convert and release locks.

$ORACLE_HOME/rdbms/admin/utllockt.sql
Prints the sessions in the system that are waiting for locks, and the
locks they are waiting for.
--
Daniel A. Morgan
http://www.psoug.org
damorgan@x.washington.edu
(replace x with u to respond)


MyLounge.com Site Map
Forum: Cars, Cell Phone, Database, Games, Home Improvement, IT, Music, School, Sports, Web Design, Web Server, Weight Loss

The MyLounge.com forum is intended for informational use only and should not be relied upon and is not a substitute for any advice. The information contained on MyLounge.com are opinions and suggestions of members and is not a representation of the opinions of MyLounge.com. MyLounge.com does not warrant or vouch for the accuracy, completeness or usefulness of any postings or the qualifications of any person responding. Please consult a expert or seek the services of an attorney in your area for more accuracy on your specific situation. Please note that our forums also serve as mirrors to Usenet newsgroups. Many posts you see on our forums are made by newsgroup users who may not be members of MyLounge.com Term of Service