Skip to content

Instantly share code, notes, and snippets.

@gupul2k
Created September 17, 2014 12:49
Show Gist options
  • Save gupul2k/17e4a49e542890feed24 to your computer and use it in GitHub Desktop.
Save gupul2k/17e4a49e542890feed24 to your computer and use it in GitHub Desktop.
Find Oracle table locks - Python script
import cx_Oracle
con = cx_Oracle.connect('scott/tiger@IPADDRESS/SID')
print con.version
cur = con.cursor()
cur.execute('select a.session_id,a.oracle_username, a.os_user_name, b.owner "OBJECT OWNER", b.object_name,b.object_type,a.locked_mode from (select object_id, SESSION_ID, ORACLE_USERNAME, OS_USER_NAME, LOCKED_MODE from v$locked_object) a, (select object_id, owner, object_name,object_type from dba_objects) b where a.object_id=b.object_id')
res = cur.fetchall()
for r in res:
print r
cur.close()
con.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment