批量kill殺死某些會話session的plsql
SQL> r
1 declare
2 v_sid v$session.sid%type; #定義如下兩個type型別,用於接收cursor
3 v_serial# v$session.serial#%type;
4 cursor cur_session is select sid,serial# from v$session where username='SCOTT';#定義cursor
1 declare
2 v_sid v$session.sid%type; #定義如下兩個type型別,用於接收cursor
3 v_serial# v$session.serial#%type;
4 cursor cur_session is select sid,serial# from v$session where username='SCOTT';#定義cursor
5 begin
6 open cur_session;#開啟cusor
6 open cur_session;#開啟cusor
7 loop #開啟遊標馬上開始迴圈,因為cursor是一條條取資料的
8 fetch cur_session into v_sid,v_serial#;#把遊標的資料放入上面定義的type變數中
8 fetch cur_session into v_sid,v_serial#;#把遊標的資料放入上面定義的type變數中
#根據以上的type變數及遊標生成批量殺session的動態sql指令碼,並執行
9 execute immediate 'alter system kill session '''||v_sid||','||v_serial#||'''';
10 exit when cur_session%notfound;#要加個異常處理,不然永遠是死迴圈
11 dbms_output.put_line('cursor date have been fetched ending');
12 end loop;#loop也有成雙匹配出現
10 exit when cur_session%notfound;#要加個異常處理,不然永遠是死迴圈
11 dbms_output.put_line('cursor date have been fetched ending');
12 end loop;#loop也有成雙匹配出現
13 close cur_session;#遊標處理完後,關閉遊標
14* end;
PL/SQL procedure successfully completed.
SQL> /
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9240380/viewspace-666622/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Kill session 和orakill 殺會話及程式總結Session會話
- 【會話】Oracle kill session系列會話OracleSession
- 根據v$session 之status及logon_time有選擇kill某些session會話SessionGo會話
- Oracle批量kill sessionOracleSession
- 無腦批量kill sessionSession
- 大話Oracle中的kill sessionOracleSession
- linux kill -9 的記錄,批量殺程式Linux
- 利用pgrep批量kill殺死多個mysqld程式MySql
- 如何批量殺死當前的MySQL程式MySql
- 【Kill】兩條Linux命令徹底殺死OracleLinuxOracle
- Session會話Session會話
- Kill會話過程分析會話
- 如何透過sid查詢造成死鎖的sql語句,並殺死會話SQL會話
- 如何通過sid查詢造成死鎖的sql語句,並殺死會話SQL會話
- Cassandra的Session會話Session會話
- MySQL: kill 會話的實現原理MySql會話
- rhel5上面awk及xargs快速殺死kill程式
- 誰將會殺死 Java?Java
- kill sessionSession
- Oracle 會話(Session)Oracle會話Session
- MySQL kill會話不起作用?MySql會話
- Kill會話過程分析(二)會話
- ORACLE快速徹底Kill掉的會話Oracle會話
- 【kill session】Oracle 徹底 kill session(轉載)SessionOracle
- 批量殺死MySQL連線的幾種方法詳解MySql
- ORA-00031:session marked for kill(標記要終止的會話)解決方法Session會話
- Oracle kill會話--sed修改檔案Oracle會話
- kill執行時間較長的會話會話
- awk -- kill sessionSession
- Oracle kill sessionOracleSession
- kill session的學問Session
- kill session的測試Session
- kill session之後,會話一直無法釋放的巧妙解決辦法(lsof)Session會話
- 最新的AI會“殺死”程式設計嗎?AI程式設計
- ora-00031:session marked for kill處理oracle中殺不掉的鎖SessionOracle
- Alter system kill session and ORA-00031: session marked for killSession
- 11g_測試kill殺死 background process後臺程式與alert
- 會話技術之 Session會話Session