report sql text of locks in database
SET ECHO off
REM NAME:Â Â Â TFSLKSQL.SQL
REM USAGE:”@path/tfslksql”
REM ————————————————————————
REM REQUIREMENTS:
REMÂ Â Â SELECT on V$SQLTEXT, V$SESSION, and V$ACCESS
REM ————————————————————————
REM PURPOSE:
REMÂ Â Â This script will report the SQL text of some of the locksÂ
REMÂ Â Â currently being held in the database.
REM ————————————————————————
REM EXAMPLE:
REMÂ Â Â USERNAMEÂ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â SID
REMÂ Â Â —————————— ———-
REMÂ Â Â OBJECT
REMÂ Â Â ——————————————————————-
REMÂ Â Â LOCKWAIT SQL
REMÂ Â Â ——– ———————————————————-
REMÂ Â Â SYSTEMÂ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 11
REMÂ Â Â SCOTT.TABLE_CONFIG
REMÂ Â Â E0034A5C update scott.table_config set tabno=99 where tabno=9
REMÂ Â Â Â
REMÂ Â Â SYSÂ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 6
REMÂ Â Â SCOTT.TABLE_CONFIG
REMÂ Â Â E0034C98 update scott.table_config set capacity=28 where capacity=4
REMÂ
REM ————————————————————————
REM Main text of script follows:
Â
set pagesize 60
set linesize 132
select s.username username,Â
      a.sid sid,Â
      a.owner||’.’||a.object object,Â
      s.lockwait,Â
      t.sql_text SQL
from  v$sqltext t,Â
      v$session s,Â
      v$access a
where t.address=s.sql_addressÂ
and   t.hash_value=s.sql_hash_valueÂ
and   s.sid = a.sidÂ
and   a.owner != ‘SYS’
and   upper(substr(a.object,1,2)) != ‘V$’
/
/*
set pagesize 60
set linesize 132
select s.username username, s.sid, s.serial#,Â
      t.sql_text SQL
from  v$sqltext t,Â
      v$session s
where t.address=s.sql_addressÂ
and   t.hash_value=s.sql_hash_value
and    s.type = ‘USER’
/
*/
Discussion ¬