> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ocient.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Query Management

export const Ocient = "Ocient®";

Query management statements let you monitor and control running queries in an {Ocient} System. For information about system tables containing query data, see [Monitoring](/system-catalog#monitoring).

## CANCEL

Cancels a running query based on its specific query identifier.

The system cancels query execution at the next available pause point, such as between batches of data processing. If the execution of the `CANCEL` SQL statement fails, you can force the query to terminate immediately by using the [KILL](/query-analysis) SQL statement.

To view active queries and their identifiers, see the [sys.queries](/system-catalog#sys-queries) table.

A `CANCEL` statement can return these statuses.

| **Status Message**    | **Description**                                                                                                                                                      |
| --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `OK`                  | The system successfully terminated the query and restored the resources assigned to its execution.                                                                   |
| `ID_NOT_FOUND`        | The specified query identifier does not exist in the system. The missing identifier can indicate that the query finished execution before the system could abort it. |
| `NOT_AUTHORIZED`      | The user does not have `UPDATE` privilege for the system level to terminate queries.                                                                                 |
| `NO_CONNECTION`       | The system lost connection to the database while trying to terminate the query.                                                                                      |
| `NETWORK_COMMS_ERROR` | Cannot communicate across the distributed system to terminate the query.                                                                                             |
| `INTERNAL_ERROR`      | The system encountered an unexpected error.                                                                                                                          |

**Required Privileges**

Users must have system-level `UPDATE` privileges to cancel queries.

**Syntax**

```sql SQL theme={null}
CANCEL query_id
```

| **Parameter** | **Type** | **Description**                                                                                                         |
| ------------- | -------- | ----------------------------------------------------------------------------------------------------------------------- |
| `query_id`    | string   | The Universally Unique IDentifier (UUID) of the query to cancel. Must be a valid UUID string enclosed in single quotes. |

**Examples**

Cancel a specific query with the `9a9eb7e3-3440-4814-871f-7f0584ac2fd8` identifier.

```sql SQL theme={null}
CANCEL '9a9eb7e3-3440-4814-871f-7f0584ac2fd8';
```

## KILL

Kills a running query identified by its UUID. This SQL statement performs a forceful termination of the query, aborting execution regardless of its current stage.

If you want to attempt a more gradual query termination that stops processing at the next pause point, use the [CANCEL](/query-analysis) SQL statement.

To view active queries and their identifiers, see the [sys.queries](/system-catalog) table.

| **Status Message**    | **Description**                                                                                                                                                     |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `OK`                  | The system successfully terminated the query and restored the resources assigned to its execution.                                                                  |
| `ID_NOT_FOUND`        | The provided query identifier does not exist in the system. The missing identifier can indicate that the query finished execution before the system could abort it. |
| `NOT_AUTHORIZED`      | The user does not have `UPDATE` privilege for the system level to terminate queries.                                                                                |
| `NO_CONNECTION`       | The system lost connection to the database while trying to terminate the query.                                                                                     |
| `NETWORK_COMMS_ERROR` | Cannot communicate across the distributed system to terminate the query.                                                                                            |
| `INTERNAL_ERROR`      | The system encountered an unexpected error.                                                                                                                         |

**Required Privileges**

Users must have system-level `UPDATE` privileges to kill queries.

**Syntax**

```sql SQL theme={null}
KILL query_id
```

**Arguments**

| **Parameter** | **Type** | **Description**                                                                       |
| ------------- | -------- | ------------------------------------------------------------------------------------- |
| `query_id`    | String   | The UUID of the query to kill. Must be a valid UUID string enclosed in single quotes. |

**Example**

Kill a specific query based on the UUID `9a9eb7e3-3440-4814-871f-7f0584ac2fd8`.

```sql SQL theme={null}
KILL '9a9eb7e3-3440-4814-871f-7f0584ac2fd8';
```

## Related Links

[System Catalog](/system-catalog)

[General SQL Syntax](/general-sql-syntax)
