如何查看oracle当前连接数,会话数 收藏
查看session:
select * from v$session where username is not null
select username,count(username) from v$session where username is not null group by username
当前连接数:
select count(*) from v$process
查看连接数参数的设置情况
select value from v$parameter where name = ‘processes’
Select count(*) from v$session where status=’ACTIVE’ #并发连接数
先查看哪些表被锁住了
select b.owner,b.object_name,a.session_id,a.locked_mode
from v$locked_object a,dba_objects b
where b.object_id = a.object_id;
select b.username,b.sid,b.serial#,logon_time
from v$locked_object a,v$session b
where a.session_id = b.sid order by b.logon_time;
杀会话
alter system kill session ‘sid,serial#’;
1.查哪个过程被锁
查V$DB_OBJECT_CACHE视图:
SELECT * FROM V$DB_OBJECT_CACHE WHERE OWNER=’过程的所属用户’ AND CLOCKS!=’0′;
2. 查是哪一个SID,通过SID可知道是哪个SESSION.
查V$ACCESS视图:
SELECT * FROM V$ACCESS WHERE OWNER=’过程的所属用户’ AND NAME=’刚才查到的过程名’;
3. 查出SID和SERIAL#
查V$SESSION视图:
SELECT SID,SERIAL#,PADDR FROM V$SESSION WHERE SID=’刚才查到的SID’
查V$PROCESS视图:
SELECT SPID FROM V$PROCESS WHERE ADDR=’刚才查到的PADDR’;
4. 杀进程
(1).先杀ORACLE进程:
ALTER SYSTEM KILL SESSION ‘查出的SID,查出的SERIAL#’;
(2).再杀操作系统进程:
KILL -9 刚才查出的SPID
或
ORAKILL 刚才查出的SID 刚才查出的SPID