查看oracle 会话详细信息
select
p.spid SRV_PID, p.USERNAME SRV_USER, p.TERMINAL SRV_TERM, p.PROGRAM SRV_PROG,
s.SID, s.SERIAL#, s.USERNAME DB_USER, s.LOGON_TIME, s.STATUS, s.OSUSER CLI_USER, s.PROCESS CLI_PID, s.MACHINE CLI_HOST, s.TERMINAL CLI_TERM, s.PROGRAM CLI_PROG
from v$process p, v$session s
where p.addr = s.paddr(+)
and p.pid <> 1;
SELECT * FROM V$SESSION T ORDER BY T.LAST_ACTIVE_TIME DESC;
desc v$session
查看进程使用时间
select osuser,a.username,cpu_time/executions/1000000||'s',sql_fulltext,
machine from v$session a,v$sqlarea b
where a.sql_address=b.address order by cpu_time/executions desc
1.查询数据库当前进程的连接数:
select count(*) from v$process;
2.查看数据库当前会话的连接数:
select count(*) from v$session;
3.查看数据库的并发连接数:
select count(*) from v$session where status='ACTIVE';
4.查看当前数据库建立的会话情况:
select sid,serial#,username,program,machine,status from v$session;
5.查询数据库允许的最大连接数:
select value from v$parameter where name = 'processes';
或者命令:show parameter processes;
查看Oracle执行过的SQL语句:
SELECT * FROM V$SQLAREA T ORDER BY T.LAST_ACTIVE_TIME DESC;
Oracle查看锁,杀会话
select * from v$lock where ctime<3600;
查看哪些会话加锁
select sid, serial# from v$session where sid='';
根据查出来的sid,查询serial
alter system kill session 'sid,serial#';
杀死会话
select spid from v$process where addr=(select paddr from v$session where sid=);
kill -9 spid
直接用操作系统命令杀死进程,更常用
查看当前打开的游标数。
select name,value from v$sysstat where name='opened cursors current';
数据库中允许的最大游标数
show parameter open_cursors;
修改最大游标
alter system set open_cursors=1000;
//打开游标的个数
select count(*) from v$open_cursor
//查看某个用户打开的游标
select * from v$open_cursor where USER_NAME='POLICE'