Home >Database >Mysql Tutorial >altersystemkillsessionimmediate

altersystemkillsessionimmediate

WBOY
WBOYOriginal
2016-06-07 15:55:502536browse

今天工作中遇到一问题:执行一个存储过程,执行了好久没有执行完,后来发现表被锁了。 select * from v$locked_object select * from user_objects where object_id = 对象id--(可以从v$locked_object表中查到) select * from V$session where sid = 会话id-

今天工作中遇到一问题:执行一个存储过程,执行了好久没有执行完,后来发现表被锁了。

select * from v$locked_object

select * from user_objects where object_id = 对象id--(可以从v$locked_object表中查到)

select * from V$session where sid = 会话id--(可以从v$locked_object表中查到,session_id)

alter system kill session 'sid serial#'--(可以从v$session查到)(用来终止会话,不释放资源)

alter system kill session 'sid serial#' immediate --(终止会话,释放资源)

在操作系统级别通过杀死线程也可以终止会话并释放资源:
select s.sid, spid, osuser, s.program
from v$process p, v$session s where p.addr=s.paddr;--(查询spid)

select instance_name from v$instance;--(查询实例名)

C:\>orakill instance_name spid --即可杀死线程释放资源,适用于windows系统.linux系统用kill -9 spid,没测试过linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn