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
Parameters |
Description |
|---|---|
| KILL CONNECTION | Compared with the version without modifiers KILL Similarly, you can terminate a given client session ID. |
| KILL QUERY | You can terminate the statement currently being executed, but the connection remains intact. |
| session_id | The Client Session ID of the current session. This ID uniquely identifies the session on the client side. You can obtain it by calling the SHOW PROCESSLIST or SHOW FULL PROCESSLIST Command query. |
Examples
Query the connected sessions and then terminate the session.
Query the connected sessions.
obclient [test]> SHOW PROCESSLIST;The return 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 session IDs in the current database, see View tenant sessions.