Updated on 2026-11-12 GMT+08:00

ALTER SYSTEM KILL SESSION

Function

During the routine O&M of a DWS database, the administrator may encounter sessions that have been running for a long time, consuming significant resources, or are in an abnormal state (such as deadlock or infinite waiting). These abnormal sessions affect the overall performance of the database and may even block other normal services. In this case, you can run the ALTER SYSTEM KILL SESSION command to terminate the session, release resources, and restore normal system operation.

The ALTER SYSTEM KILL SESSION command is used to terminate a specified database session. By providing the SID and SERIAL identifiers of the session, you can precisely terminate the target session and release the system resources it occupies.

Precautions

None

Syntax

1
ALTER SYSTEM KILL SESSION 'session_sid, serial' [ IMMEDIATE ];

Parameter Description

Table 1 ALTER SYSTEM KILL SESSION parameters

Parameter

Description

Value Range

session_sid, serial

Specifies the identifier of the session to be terminated. It consists of the session SID and SERIAL, which are separated by a comma (,).

The SIDs and SERIALs of all sessions that can be queried from the system catalog V$SESSION.

IMMEDIATE

Indicates that a session will be ended instantly after the command is executed.

-

Examples

Query session information.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
SELECT sid,serial#,username FROM V$SESSION;

       sid       | serial# | username 
-----------------+---------+----------
 140131075880720 |       0 | 
 140131025549072 |       0 | 
 140131073779472 |       0 | 
 140131071678224 |       0 | 
 140131125774096 |       0 | 
 140131127875344 |       0 | 
 140131113629456 |       0 | 
 140131094742800 |       0 | 
(8 rows)

End the session whose SID is 140131075880720.

1
ALTER SYSTEM KILL SESSION '140131075880720,0' IMMEDIATE;