Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL Statements
Puneet Khanna a écrit dans le message <7n7e0v$7hb$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
>
>
select sum(decode(key, 'STARTUP TIME - JULIAN',
(to_number(to_char(sysdate, 'J'))-value)*86400, 'STARTUP TIME - SECONDS', to_number(to_char(sysdate, 'SSSSS'))-value, 0)) "Elapsed (s)"from V$INSTANCE
2. select count(*) "Nb User" from v$session where type='USER';
3. I don't know what you mean by "any locking problem".
The following query gives the list of the locks hold and waiting.
Actually, it displays the user, his session id, the status of the session,
the OS process id, the lock type and the lock mode, if it is waiting
and the object locked or requested:
Column user_ FORMAT a11 HEADING User
Column sid_ FORMAT a10 HEADING Sid
Column status FORMAT a08 HEADING Status
Column process FORMAT a06 HEADING "OS Pid" TRUNC Column LK FORMAT a02
p.spid process, l.type LK, decode(l.lmode+l.request, 0, 'NO' /* no lock requested */, 1, ' ' /* null */, 2, 'RS' /* row share */, 3, 'RX' /* row exclusive */, 4, 'S' /* share */, 5, 'SRX' /* share row exclusive */, 6, 'X' /* exclusive */, to_char(l.lmode+l.request)) mode_, decode(l.request, 0, ' ', 'W') wait_, decode(l.type||to_char(l.lmode+l.request), 'TX6', decode(l.id2, 0, decode(o.object_name, NULL, l.id1||'/'||l.id2, o.owner||'.'||o.object_name), decode(r.name, NULL, l.id1||'/'||l.id2, r.name)), 'TS6', 'Temporaire '||TRUNC(l.id1/16777216)||'.'||mod(l.id1,16777216), decode(o.object_name, NULL, l.id1||'/'||l.id2, o.owner||'.'||o.object_name)) objet_from dba_objects o, v$rollname r, v$process p, v$session s, v$lock l
where o.object_id (+) = l.id1 and r.usn (+) = TRUNC(l.id1/65536) and p.addr = s.paddr and s.sid = l.sid and l.type in ('RW', 'TM', 'TS', 'TX', 'UL');Received on Tue Aug 03 1999 - 09:43:40 CDT
![]() |
![]() |