×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Oracle Locks

Oracle Locks

Oracle Locks

(OP)
I was wondering if anyone has a simple script that they could pass on which would help me to identiy any locks within an active database.

I know I could use the SQL Lock Manager but I'd rather not.

Many thanks.

RE: Oracle Locks

According to the book I got, there is a V$LOCK table that lists the locks currently taken out against this instance.   So, try the following:

SELECT * FROM V$LOCK;

HTH

Terry M. Hoey
th3856@txmail.sbc.com

Ever notice that by the time that you realize that you ran a truncate script on the wrong instance, it is too late to stop it?

RE: Oracle Locks

(OP)
Thanks for that, the problem is that it dosn't give very much information, I was thinking more of a script which tells me if the lock type is
RS - Row Share
RX - Row Exclusive
S - Share
SRX - Share Row Exclusive
X - Exclusive

I found the following script on the internet but was wondering if anyone had any other suggestions - preferably something simpler.

select o.name "TABLE", s.username, l.type, l.id1 dummy, l.id2 dummy,
decode(l.lmode,
0, '',
1, '*NULL',                       
2, '*RS',                      
3, '*RX',                       
4, '*S',                       
5, '*SRX',                       
6, '*X',                      
'*' || to_char(l.lmode)) ||
decode(l.request,
0, '',                       
1, ' NULL',
2, ' RS',                        
3, ' RX',                         
4, ' S',                         
5, ' SRX',                         
6, ' X',                        
' ' || to_char(l.request)) "MODE",
a.sql_text
from v$session s, v$sqlarea a, sys.obj$ o, v$lock l
where l.sid = s.sid
  and l.id1 = o.obj# (+)
  and s.sql_address = a.address
  and s.sql_hash_value = a.hash_value
  and s.username is not null

Many thanks

RE: Oracle Locks

You might try running the utllockt.sql script that should by in your ADMIN subdirectory (with all of the other utl scripts).  Not only will it give you output of the locks that are being held, but will also show any sessions that are waiting for the locks to go away.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close