Purpose
This statement is used to terminate a session.
Note
If you have the PROCESS privilege, you can view all sessions. If you have the SUPER privilege, you can terminate all sessions and statements. Otherwise, you can only view and terminate your own sessions and statements.
Syntax
KILL [CONNECTION | QUERY] 'session_id'
Parameters
| Parameter | Description |
|---|---|
| KILL CONNECTION | Similar to the KILL statement without modifiers, it terminates the specified Client Session ID. |
| KILL QUERY | Terminates the statement currently being executed on the connection, but keeps the connection intact. |
| session_id | The Client Session ID of the current session, which uniquely identifies the session on the client side. You can query it using the SHOW PROCESSLIST or SHOW FULL PROCESSLIST statement. |
Examples
Query the connected sessions and then terminate the session.
Query the connected sessions.
obclient [test]> SHOW PROCESSLIST;The returned result is as follows:
+------------+------+----------------------+------+---------+-------+--------+------------------+ | Id | User | Host | db | Command | Time | State | Info | +------------+------+----------------------+------+---------+-------+--------+------------------+ | 3221487617 | root | xxx.xx.xxx.xxx:54284 | NULL | Sleep | 21560 | SLEEP | NULL | | 3221487619 | root | xxx.xx.xxx.xxx:21977 | test | Query | 0 | ACTIVE | SHOW PROCESSLIST | | 3221487628 | root | xxx.xx.xxx.xxx:58550 | NULL | Sleep | 9 | SLEEP | NULL | +------------+------+----------------------+------+---------+-------+--------+------------------+ 3 rows in setTerminate the session.
obclient [test]> KILL 3221487617;
References
For more information about querying the number of sessions and their IDs in the current database, see View tenant sessions.
