Jak wyświetlać aktywne / otwarte połączenia w Oracle?

Czy jest jakaś ukryta tabela, zmienna systemowa lub coś do pokazania aktywnych połączeń w danej chwili?

 135
Author: ROMANIA_engineer, 2009-06-25

9 answers

Użyj V$SESSION widok.

V$SESSION wyświetla informacje o sesji dla każdej bieżącej sesji.

 157
Author: PaulJWilliams,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-02-19 08:37:48

Aby uzyskać pełniejszą odpowiedź zobacz: http://dbaforums.org/oracle/index.php?showtopic=16834

select
       substr(a.spid,1,9) pid,
       substr(b.sid,1,5) sid,
       substr(b.serial#,1,5) ser#,
       substr(b.machine,1,6) box,
       substr(b.username,1,10) username,
--       b.server,
       substr(b.osuser,1,8) os_user,
       substr(b.program,1,30) program
from v$session b, v$process a
where
b.paddr = a.addr
and type='USER'
order by spid; 
 91
Author: ehrhardt,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-02-01 09:50:33

Kiedy chcę przeglądać połączenia przychodzące z naszych serwerów aplikacji do bazy danych używam następującego polecenia:

SELECT username FROM v$session 
WHERE username IS NOT NULL 
ORDER BY username ASC;
Proste, ale skuteczne.
 26
Author: user2021477,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-01-29 11:33:02
select
  username,
  osuser,
  terminal,
  utl_inaddr.get_host_address(terminal) IP_ADDRESS
from
  v$session
where
  username is not null
order by
  username,
  osuser;
 5
Author: user3848789,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-06-15 06:37:53

Poniżej znajduje się lista użytkowników systemu operacyjnego posortowanych według liczby połączeń, co jest przydatne w przypadku nadmiernego wykorzystania zasobów.

select osuser, count(*) as active_conn_count 
from v$session 
group by osuser 
order by active_conn_count desc
 4
Author: jediz,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-10-04 20:57:00
Select count(1) From V$session
where status='ACTIVE'
/
 3
Author: Juber,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-06-15 06:37:40
select status, count(1) as connectionCount from V$SESSION group by status;
 3
Author: user3285705,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-12-08 22:48:58
select s.sid as "Sid", s.serial# as "Serial#", nvl(s.username, ' ') as "Username", s.machine as "Machine", s.schemaname as "Schema name", s.logon_time as "Login time", s.program as "Program", s.osuser as "Os user", s.status as "Status", nvl(s.process, ' ') as "OS Process id"
from v$session s
where nvl(s.username, 'a') not like 'a' and status like 'ACTIVE'
order by 1,2

To zapytanie próbuje odfiltrować wszystkie procesy działające w tle.

 3
Author: Alan,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-11-21 09:21:49
select 
    count(1) "NO. Of DB Users", 
    to_char(sysdate,'DD-MON-YYYY:HH24:MI:SS') sys_time
from 
    v$session 
where 
    username is NOT  NULL;
 1
Author: kirankumar M,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-05-24 00:45:58