首页 > 代码库 > 关于会话、进程、请求的几个常用SQL
关于会话、进程、请求的几个常用SQL
1.检查自己的SID
SELECT sid FROM v$session WHERE sid = (SELECT sid FROM v$mystat WHERE rownum = 1);
2. 几个ID之间的关系
SELECT s.sid session_id, p.spid os_process_id, p.pid oracle_process_id FROM v$process p, v$session s WHERE p.addr = s.paddr;
3.杀死Session和进程
SELECT s.sid session_id, p.spid os_process_id, p.pid oracle_process_id, 'alter system kill session ''' || to_char(s.sid) || ',' || to_char(s.serial#) || ''' immediate;' kill_db_session, 'kill -9 ' || p.spid kill_os_session FROM v$process p, v$session s WHERE p.addr = s.paddr AND s.sid = &sid;
4.正在执行的SQL
SELECT sql_text FROM v$sqltext_with_newlines sqlt, v$session s WHERE sqlt.address = s.sql_address AND sqlt.hash_value = http://www.mamicode.com/s.sql_hash_value>
5.引用对象的Session,锁表session
SELECT acc.*, 'alter system kill session ''' || to_char(ses.sid) || ',' || to_char(ses.serial#) || ''' immediate' FROM v$access acc, v$session ses WHERE acc.OBJECT LIKE upper('TABLE_NAME%') AND acc.sid = ses.sid;
6.请求的Session和SQL<span style="font-size:18px;">SELECT to_char(s.sid) || ',' || to_char(s.serial#), sql_text FROM applsys.fnd_concurrent_requests r, v$process p, v$session s, v$sqltext_with_newlines sqlt WHERE r.oracle_process_id = p.spid AND p.addr = s.paddr(+) AND s.sql_address = sqlt.address(+) AND s.sql_hash_value = http://www.mamicode.com/sqlt.hash_value(+)>
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。