oracle 如何找到正在运行的SQL_ID

#根据sql内容查找sql_id和sql的发起方式
select sql_id,module from v$sql where last_active_time > sysdate and sql_text like '%dba_free_space%';
#生成杀进程的sql
select 'ALTER SYSTEM KILL SESSION'''||sid||','||serIal#||''''||';' from v$session where sql_id='12sd234erdf23';
select * from gv$session where sql_id='12sd234erdf23'; #获取会话信息
alter system kill session '1231,23423' immediate; #立即杀掉会话

select * from gv$sql where sql_id='12sd234erdf23'  #根据sql_id查找sql

SELECT sql_id, sql_text
FROM v$sql
WHERE sql_text LIKE '%your_search_pattern%';

 

SELECT sql_id, sql_text
FROM dba_hist_sqltext
WHERE sql_text LIKE '%your_search_pattern%'
AND snapshot_id = (SELECT MAX(snapshot_id) FROM dba_hist_sqlstat);

 

参考 :https://www.cnblogs.com/wukc/p/17613341.html

posted @ 2024-06-15 22:46  seasonzone  阅读(5)  评论(0编辑  收藏  举报