You are on page 1of 3

10/01/2018 How to list active / open connections in Oracle?

- Stack Overflow

It's back! Take the 2018 Developer Survey today »

Stack Overflow is a community of 8.3 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up ×

How to list active / open connections in Oracle?

Is there any hidden table, system variable or something to show active connections in a
given moment?

oracle

edited Oct 20 '14 at 11:18 asked Jun 25 '09 at 10:19


ROMANIA_engineer pistacchio
24.7k 15 114 119 19k 73 216 329

9 Answers

Use the V$SESSION view.

V$SESSION displays session information for each current session.

edited Feb 19 '16 at 8:37 answered Jun 25 '09 at 10:21


Yogesh lele PaulJWilliams
137 1 10 15.4k 1 41 73

3 Error starting at line 1 in command: select * from FROM v$session Error at Command Line:1 Column:14
Error report: SQL Error: ORA-00903: invalid table name 00903. 00000 - "invalid table name" *Cause:
*Action: – pistacchio Jun 25 '09 at 10:22

3 Either you don't have permissions, or you didn't install the DBA views correctly. – S.Lott Jun 25 '09 at 10:24

4 You'll need the select_catalog_role role. – PaulJWilliams Jun 25 '09 at 10:25

2 You can join v$sqltext to get the current SQL of sessions too. – Alkini Jun 25 '09 at 16:46

18 pistacchio, you have 2 "from FROM" in the SQL: "select * from FROM v$session" – Marc Prud'hommeaux
Nov 23 '10 at 20:02

For a more complete answer see: 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;

answered Feb 1 '12 at 9:50


ehrhardt
1,603 14 12

When I'd like to view incoming connections from our application servers to the database I use
the following command:

SELECT username FROM v$session


WHERE username IS NOT NULL
ORDER BY username ASC;

https://stackoverflow.com/questions/1043096/how-to-list-active-open-connections-in-oracle 1/3
10/01/2018 How to list active / open connections in Oracle? - Stack Overflow
Simple, but effective.

answered Jan 29 '13 at 11:33


user2021477
241 2 2

select
username,
osuser,
terminal,
utl_inaddr.get_host_address(terminal) IP_ADDRESS
from
v$session
where
username is not null
order by
username,
osuser;

edited Jun 15 '15 at 6:37 answered Jul 17 '14 at 10:50


josliber ♦ user3848789
35.2k 11 54 88 61 1 1

4 Welcome to SO! Please provide some intuition for your answers. – vefthym Jul 17 '14 at 10:56

select status, count(1) as connectionCount from V$SESSION group by status;

edited Dec 8 '16 at 22:48 answered Jun 16 '15 at 15:05


Tunaki user3285705
76k 21 148 200 31 1

The following gives you list of operating system users sorted by number of connections, which
is useful when looking for excessive resource usage.

select osuser, count(*) as active_conn_count


from v$session
group by osuser
order by active_conn_count desc

edited Oct 4 '17 at 20:57 answered Jul 27 '16 at 10:04


maxschlepzig jediz
10.3k 6 60 89 903 1 16 22

Select count(1) From V$session


where status='ACTIVE'
/

edited Jun 15 '15 at 6:37 answered Jun 15 '15 at 6:31


josliber ♦ Juber
35.2k 11 54 88 21 1

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;

edited May 24 '17 at 0:45 answered Mar 7 '17 at 6:09


miracle173 kirankumar M
1,133 8 22 7 2

1 While this code snippet may solve the question, including an explanation really helps to improve the quality
of your post. Remember that you are answering the question for readers in the future, and those people
might not know the reasons for your code suggestion. – DimaSan Mar 7 '17 at 11:06

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",

https://stackoverflow.com/questions/1043096/how-to-list-active-open-connections-in-oracle 2/3
10/01/2018 How to list active / open connections in Oracle? - Stack Overflow
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

This query attempts to filter out all background processes.

edited Nov 21 '17 at 9:21 answered Nov 21 '17 at 9:06


Yahya Hussein Alan
1,182 11 24 11 1

https://stackoverflow.com/questions/1043096/how-to-list-active-open-connections-in-oracle 3/3

You might also like