Created
September 17, 2014 12:49
-
-
Save gupul2k/17e4a49e542890feed24 to your computer and use it in GitHub Desktop.
Find Oracle table locks - Python script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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