Purpose
You can use this statement to terminate a session.
Note
In Oracle mode, a regular user can view and terminate only their own sessions. A tenant administrator can view and terminate all sessions. If a regular user has the SHOW PROCESS privilege, they can view all sessions.
Syntax
KILL [CONNECTION | QUERY] 'session_id'
Parameters
Parameter |
Description |
|---|---|
| KILL CONNECTION | It is equivalent to the KILL statement with no modifier and can be used to terminate a session specified by the client session ID. |
| KILL QUERY | Terminates the statement that is being executed by the session but leaves the session intact. |
| session_id | The client session ID of the current session, which is the unique identifier of a session in a client. You can execute the SHOW PROCESSLIST or SHOW FULL PROCESSLIST statement to obtain the session ID. |
Examples
Query and then terminate a session.
obclient> SHOW PROCESSLIST;
+------------+------+-------------------+------+---------+------+--------+------------------+
| ID | USER | HOST | DB | COMMAND | TIME | STATE | INFO |
+------------+------+-------------------+------+---------+------+--------+------------------+
| 3221849635 | SYS | 10.10.10.10:49142 | SYS | Sleep | 426 | SLEEP | NULL |
| 3221656012 | SYS | 10.10.10.10:57140 | SYS | Sleep | 426 | SLEEP | NULL |
| 3221671483 | SYS | 10.10.10.10:43154 | SYS | Query | 0 | ACTIVE | show processlist |
+------------+------+-------------------+------+---------+------+--------+------------------+
3 rows in set
obclient> KILL 3221849635;
Query OK, 0 rows affected
obclient> KILL QUERY 3221656012;
Query OK, 0 rows affected
obclient> KILL CONNECTION 3221671483;
Query OK, 0 rows affected
References
For more information about how to query the quantity and IDs of sessions in the current database, see View tenant sessions.
