CANCEL SESSION lets you stop long-running sessions. CANCEL SESSION will attempt to cancel the currently active query and end the session.
Required privileges
To view and cancel a session, the user must be a member of theadmin role or must have the VIEWACTIVITY (or the legacy ) and the CANCELQUERY (or the legacy ) defined. Non-admin users cannot cancel admin users’ sessions.
Synopsis
Parameters
| Parameter | Description |
|---|---|
session_id | The ID of the session you want to cancel, which can be found with .CANCEL SESSION accepts a single session ID. If a subquery is used and returns multiple IDs, the CANCEL SESSION statement will fail. To cancel multiple sessions, use CANCEL SESSIONS. |
select_stmt | A that returns session_id(s) to cancel. |
Example
Cancel a single session
In this example, we use the statement to get the ID of a session and then pass the ID into theCANCEL SESSION statement:
Cancel multiple sessions
Use the statement to view all active sessions:session_id(s) inside the CANCEL SESSIONS statement:
maxroach will be cancelled.

