Wednesday, 4 June 2014

Table Locking Information in SQL/PLUS

SET LINESIZE 10000
SET TRIMSPOOL ON
set timing off

prompt ******************** Table Locking Information *******************************************
SELECT SUBSTR(B.OWNER,1,8) "Owner",
B.OBJECT_TYPE,
SUBSTR(B.OBJECT_NAME,1,18) "Object_name" ,
DECODE(A.LOCKED_MODE,0,'None' ,1,'Null' ,
2,'Row-S',3,'Row-X' ,
4,'Share',5,'S/Row-X',
6,'Exclusive') "Locked_Mode",
A.SESSION_ID "Sess_ID",
SUBSTR(A.ORACLE_USERNAME,1,10) "User_name",
A.OS_USER_NAME "OS_User",
to_char(c.logon_time,'YYYY/MM/DD HH24:MI:SS') "Logon_Time"
FROM V$LOCKED_OBJECT A,DBA_OBJECTS B,v$session c
WHERE A.OBJECT_ID=B.OBJECT_ID
and a.session_id=c.sid
ORDER BY B.OWNER,B.OBJECT_TYPE,B.OBJECT_NAME;
prompt ******************* User Transactions Information ****************************************
column "UserName" format a8
column "DB Sid" format 999999
column "Unix Pid" format 99999999
column "Trnx_start_time" format a19
column "Current Time" format a19
column "Elapsed(mins)" format 999999999.99
column "Undo Name" format a09
column "Used Undo Blks" format a13
column "Used Undo Size(Kb)" format a17
column "Logical I/O(Blks)" format 99999999999999999
column "Logical I/O(Kb)" format 999999999999999
column "Physical I/O(Blks)" format 999999999999999999
column "Physical I/O(Kb)" format 999999999999999999
select a.username "UserName" ,
a.sid "DB Sid",
e.spid "Unix Pid",
to_char(to_date(b.start_time,'mm/dd/yy hh24:mi:ss'),'yyyy/mm/dd hh24:mi:ss') "Trnx_start_time",
to_char(sysdate,'yyyy/mm/dd hh24:mi:ss') "Current Time",
round(60*24*(sysdate-to_date(b.start_time,'mm/dd/yy hh24:mi:ss')),2) "Elapsed(mins)",
c.segment_name "Undo Name",
to_char(b.used_ublk*d.value/1024) "Used Undo Size(Kb)",
to_char(b.used_ublk) "Used Undo Blks",
b.log_io "Logical I/O(Blks)" ,
b.log_io*d.value/1024 "Logical I/O(Kb)",
b.phy_io "Physical I/O(Blks)",
b.phy_io*d.value/1024 "Physical I/O(Kb)",
a.PROGRAM
from v$session a,
v$transaction b,
dba_rollback_segs c,
v$parameter d,
V$PROCESS e
where b.ses_addr=a.saddr
and b.xidusn=c.segment_id
and d.name='db_block_size'
and e.ADDR=a.PADDR
order by 4;
prompt *****************************************************************
Set timing on
SET HEADING ON

No comments:

Post a Comment