View user connections
Disconnect a connection
View connection IP
View user connections in Oracle
Select username, Sid, serial #, status from V $ session where username <> '1 ';
Select Sid, SES. Serial #, SES. username, Pro. username, Pro. spid, status
From v $ session SES, V $ process pro
Where SES. Username = 'product' and SES. paddr = pro. ADDR;
Select SES. username, Pro. * from V $ process pro, V $ session ses where SES. paddr = pro. ADDR and SES. Username <> '1 ';
From the preceding SQL statement, you can obtain the connected user, Oracle SID, and OS process number.
With the above information, you can stop the connection
Alter system kill session 'sid, serial # '; or directly kill the session according to the OS process number.
The preceding SQL statement cannot obtain the IP address of the connected client. Is there any ready-made view available?
To obtain an IP address
Method 1: $ ORACLE_HOME/Network/log/listener_orarac1.log
Method 2: Create a logon trigger
Create Table session_history...
Create or replace trigger logon_history
after logon database
begin
insert into session_history
select username, sysdate, sys_context ('userenv ', 'IP _ address') from V $ session where audsid = userenv ('sessionid');
commit;
end;
Method 3: netstat-anp | grep 1521
TCP 0 0 192.168.1.52: 1521 192.168.2.101: 45877 established 5582/oracleorcl1
TCP 0 0 192.168.1.52: 1521 192.168.2.101: 37343 established 5588/oracleorcl1
TCP 0 0 192.168.1.52: 1521 192.168.2.101: 50172 established 24184/oracleorcl1
TCP 0 0 192.168.1.52: 1521 192.168.2.101: 59023 established 5584/oracleorcl1
TCP 0 0 192.168.1.52: 1521 192.168.10.23: 1992 established 29055/oracleorcl1
TCP 0 0 192.168.1.52: 1521 192.168.2.101: 51121 established 5586/oracleorcl1
TCP 0 0 192.168.1.52: 1521 192.168.2.102: 44376 established 18104/oracleorcl1
TCP 0 0 192.168.1.52: 1521 192.168.2.102: 51209 established 27165/oracleorcl1
TCP 0 0 192.168.1.52: 1521 192.168.2.102: 59845 established 18102/oracleorcl1
TCP 0 0 192.168.1.52: 1521 192.168.2.102: 41867 established 22780/oracleorcl1
5582 in oracleorcl1 is the OS process number.