Terminating Sessions
当一个会话被终止时,该会话所有的事务会被回滚,相应的资源(locks memory areas)也会立即被释放。
sql statement :alter system kill session '7,15';
1.确定哪些会话需要终止
SELECT SID, SERIAL#, STATUS
FROM V$SESSION
WHERE USERNAME = 'JWARD';
SID
SERIAL#
STATUS
----- ---------
--------
7
15
ACTIVE
12
63
INACTIVE
ACTIVE
--》 making a SQL call to Oracle Database.
INACTIVE --》 not making a SQL call to the database
2.干掉session
alter system kill session '7,15';
注意:An active session cannot be interrupted when it is performing network I/O or rolling back a transaction. Such a session cannot be terminated until the operation completes. In this case, the session holds all resources until it is terminated.
Additionally, the
session that issues the ALTER SYSTEM statement to terminate a session waits up to 60 seconds for the session to be terminated. If
the operation that cannot be interrupted continues past one minute, the issuer of the
ALTER SYSTEM statement receives a message indicating that the session has been marked to be terminated. A session marked to be terminated is indicated in V$SESSION with a status of
KILLED
and a server that is something other than
PSEUDO 。
3.干掉an Inactive Session
SELECT SID,SERIAL#,STATUS,SERVER
FROM V$SESSION
WHERE USERNAME = 'JWARD';
SID
SERIAL#
STATUS
SERVER
----- --------
---------
---------
7
15
INACTIVE
DEDICATED
12
63
INACTIVE
DEDICATED
2 rows selected.
ALTER SYSTEM KILL SESSION '7,15';
Statement processed.
确定下session 是否已经被kill了
SELECT SID, SERIAL#, STATUS, SERVER
FROM V$SESSION
WHERE USERNAME = 'JWARD';
SID
SERIAL#
STATUS
SERVER
----- --------
---------
---------
7
15
KILLED
PSEUDO
12
63
INACTIVE
DEDICATED
2 rows selected.
当一个会话被终止时,该会话所有的事务会被回滚,相应的资源(locks memory areas)也会立即被释放。
sql statement :alter system kill session '7,15';
1.确定哪些会话需要终止
SID
-----
12
INACTIVE
2.干掉session
注意:An active session cannot be interrupted when it is performing network I/O or rolling back a transaction. Such a session cannot be terminated until the operation completes. In this case, the session holds all resources until it is terminated.
Additionally, the
session that issues the
3.干掉an Inactive Session
SELECT SID,SERIAL#,STATUS,SERVER
SID
-----
2 rows selected.
ALTER SYSTEM KILL SESSION '7,15';
Statement processed.
确定下session 是否已经被kill了
SELECT SID, SERIAL#, STATUS, SERVER
SID
-----
2 rows selected.