Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: SQL Statements
Hi!
I hope These scripts will help you...
Oracle Enterprise Manager is very helpful tools.. but it also dependent on
Oracle internal functions...
I think REAL Oracle DBAs must know the Internal Oracle Architecture and
freely deal with them...
May the Force be with you!!
From Cho..
creamino_at_lgsoft.com
-- -- who.sql -- SELECT substr(nvl(S.OSUSER,s.type),1,7) OS_User, substr(nvl(S.USERNAME,'Bg'),1,7) DBUser, to_char(S.sid,'9999') SID, to_char(S.serial#,'999') Ser, to_char(P.pid,'99999') ORAPID, -- substr(s.program,1,15) PGM, S.process F_Ground, P.spid B_Ground, S.status FROM V$SESSION S, V$PROCESS P
-- -- lock.sql -- --
col un format a11 heading 'Ora User' col ou format a11 heading 'OS User' col ob format a19 heading 'On object'
col id1 format 9999999 heading 'Obj ID' col ty format a4 heading 'Type' col mh format a4 heading 'Held'
select username un, osuser ou, s.sid sid , s.serial# ser, l.type ty,
decode(lmode,1,'NONE',2,'RS',3,'RX',4,'S',5,'RSX',6,'X') mh, o.name ob, id1, decode(request,1,'NONE',2,'RS',3,'RX',4,'S',5,'RSX',6,'X') mrfrom v$lock l, v$session s, obj$ o
Doc
Name: lockhldr.sql
This script lists the users that are currently holding locks that are currently blocking users as well as the users that are being blocked. It also lists the offending objects (tables, etc).
#
set heading on
ttitle 'User Blocking and Waiting for Other Users'
select distinct o.object_name,
sh.username||'('||sh.sid||')' "Holder", sw.username||'('||sw.sid||')' "Waiter", decode(lh.lmode, 1, 'null', 2, 'row share', 3, 'row exclusive', 4, 'share', 5, 'share row exclusive' , 6, 'exclusive') "Lock Type"from all_objects o, v$session sw, v$lock lw, v$session sh, v$lock lh where lh.id1 = o.object_id
and lh.id1 = lw.id1 and sh.sid = lh.sid and sw.sid = lw.sid and sh.lockwait is null and sw.lockwait is not null and lh.type = 'TM' and lw.type = 'TM'
Puneet Khanna <7n7dvq$7gc$1_at_nntp3.uunet.ca>
>I want to know SQL statements for -
>
>1. Checking how long database instance is up.
>2. How many active users are in the system.
>3. Are there any locking problems.
>
>Thanks in advance,
>Puneet
>
>
Received on Fri Jul 23 1999 - 04:37:43 CDT