Purpose
You can use this statement to terminate a session.
Note
If you have the PROCESS privilege, you can view all sessions. If you have the SUPER privilege, you can end all sessions and SQL statements. Otherwise, you can view and end only your own session and SQL statements.
Syntax
KILL [CONNECTION | QUERY] 'session_id'
Parameters
| Parameter | Description |
|---|---|
| KILL | Ends a session specified by session_id. Note: You can execute the SHOW PROCESSLIST; SQL statement to view session_id. |
| KILL CONNECTION | It is equivalent to the KILL statement with no modifier and can be used to end a session specified by session_id. |
| KILL QUERY | Ends the statement that is being executed by the session but leaves the session intact. |
| session_id | The unique ID of the session. |
Examples
Query and then end 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