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 SQL statements. Otherwise, you can only view and terminate your own sessions and SQL statements.
Syntax
KILL [CONNECTION | QUERY] 'session_id'
Parameters
| Parameter | Description |
|---|---|
| KILL CONNECTION | Same as KILL without modifiers, it terminates the specified Client Session ID. |
| KILL QUERY | Terminates the statement currently being executed, but keeps the session connected. |
| session_id | The Client Session ID of the current session, which uniquely identifies the session on the client. You can query it using the SHOW PROCESSLIST or SHOW FULL PROCESSLIST command. |
Examples
Query connected sessions and then terminate a session.
obclient> SHOW PROCESSLIST;
Expected return result:
+------------+------+----------------------+------+---------+------+--------+------------------+
| 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
Terminate a session:
obclient> KILL 3221849635;
obclient> KILL QUERY 3221656012;
obclient> KILL CONNECTION 3221671483;
References
For more information about querying the number of sessions and their IDs in the current database, see View Tenant Sessions.