KILL is an administrative statement used to abort an active connection (session) or the statement currently executing in that connection. It is available in MySQL/MariaDB and SQL Server (as well as Sybase ASE). When executed, the server sends a signal to the target process, rolls back any uncommitted work, and releases locks and memory. In MySQL you can choose to kill either the whole connection or only the query. In SQL Server you can monitor rollback progress with WITH STATUSONLY. Because KILL can disrupt work and cause rollback overhead, it is restricted to high-level privileges (CONNECTION_ADMIN or SUPER in MySQL, sysadmin or processadmin in SQL Server). KILL never affects the session issuing the command unless its own ID is specified. It is not part of the ANSI/ISO SQL standard and is unsupported in PostgreSQL, Oracle, or SQLite, which offer their own functions to terminate sessions.
thread_id
(integer) - MySQL: The value from SHOW PROCESSLIST.ID designating the thread to kill.CONNECTION | QUERY
(keyword) - MySQL: CONNECTION ends the session; QUERY stops only the current statement.session_id
(integer) - SQL Server: The session_id from sys.dm_exec_sessions to terminate.WITH STATUSONLY
(clause) - SQL Server: Returns estimated rollback progress without killing the session.UOW
(GUID) - SQL Server: Optional. Ends a specific distributed transaction by Unit of Work ID.SHOW PROCESSLIST, pg_terminate_backend, ALTER SYSTEM KILL SESSION, sys.dm_exec_sessions, ROLLBACK
MySQL 3.23 (1999)
The server automatically rolls back any uncommitted transactions belonging to the killed session to keep the database consistent.
In MySQL use `KILL QUERY thread_id`. SQL Server does not distinguish; you must terminate the whole session.
Use `SHOW PROCESSLIST` in MySQL or query `sys.dm_exec_sessions` in SQL Server to list active sessions and their IDs.
Yes. Both MySQL and SQL Server record the kill action in the error log and/or system views, allowing administrators to audit who executed it.