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

# DROP RESOURCE GROUP

The `DROP RESOURCE GROUP` [statement](https://docs.cockroachlabs.com/docs/stable/sql-statements.md) removes a [resource group](https://docs.cockroachlabs.com/docs/stable/resource-groups.md).

> [!NOTE]
>
> **This feature is in [preview](https://docs.cockroachlabs.com/docs/releases/cockroachdb-feature-availability.md)** and subject to change. To share feedback and/or issues, contact [Support](https://support.cockroachlabs.com).

To use `DROP RESOURCE GROUP`, you must first [enable resource groups](https://docs.cockroachlabs.com/docs/stable/resource-groups.md#enable-resource-groups).

## Required privileges

Only members of the [`admin` role](https://docs.cockroachlabs.com/docs/stable/security-reference/authorization#admin-role) can drop resource groups.

## Synopsis

![drop\_resource\_group syntax diagram](https://mintcdn.com/cockroachlabs/iBfszXHb4tKmDGVE/images/sql-diagrams/v26.4/drop_resource_group.svg?fit=max\&auto=format\&n=iBfszXHb4tKmDGVE\&q=85\&s=1fb8d5d5f1968bc28ab2f1ebe1fa7cd6)

## Parameters

| Parameter | Description |
| - | - |
| `IF EXISTS` | Drop the resource group only if it exists. If it does not exist, the statement does nothing and does not return an error. |
| `name` | The name of the resource group to drop. |

## Considerations

`DROP RESOURCE GROUP` does not check whether sessions, roles, or databases are assigned to the resource group. After a group is dropped:

* Sessions that are assigned to the group keep the group name in their `resource_group` [session variable](https://docs.cockroachlabs.com/docs/stable/set-vars.md). Their work runs in the built-in [default resource group](https://docs.cockroachlabs.com/docs/stable/resource-groups.md#built-in-resource-groups), and the session receives a notice.
* Role and database defaults that name the group are not removed. New sessions that use those defaults also run in the default resource group.

To find role and database defaults that name a resource group before you drop it, use [`SHOW DEFAULT SESSION VARIABLES FOR ROLE`](https://docs.cockroachlabs.com/docs/stable/show-default-session-variables-for-role).

## Examples

### Drop a resource group

The following statements create a resource group named `batch` and then drop it:

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
CREATE RESOURCE GROUP batch WITH (cpu_weight = 100);
```

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
DROP RESOURCE GROUP batch;
```

### Drop a resource group only if it exists

The following statement does nothing, because the `batch` resource group no longer exists:

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
DROP RESOURCE GROUP IF EXISTS batch;
```

Without `IF EXISTS`, the statement returns an error:

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
DROP RESOURCE GROUP batch;
```

```
ERROR: resource group "batch" does not exist
SQLSTATE: 42704
```

### Drop a resource group that a session is assigned to

The following statements create a resource group named `reporting` and assign the current session to it:

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
CREATE RESOURCE GROUP reporting WITH (cpu_weight = 100);
```

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
SET resource_group = 'reporting';
```

Drop the resource group:

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
DROP RESOURCE GROUP reporting;
```

After the change reaches the node, the session's work runs in the default resource group, and a statement in the session returns a notice. The `resource_group` session variable still shows the dropped group's name:

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
SHOW resource_group;
```

```
NOTICE: resource group "reporting" not found; no resource group applied to this session
  resource_group
------------------
  reporting
(1 row)
```

To assign the session to a resource group that exists, set the `resource_group` session variable again, or reset it with `RESET resource_group`.

## See also

* [Resource Groups](https://docs.cockroachlabs.com/docs/stable/resource-groups.md)
* [`CREATE RESOURCE GROUP`](https://docs.cockroachlabs.com/docs/stable/create-resource-group)
* [`ALTER RESOURCE GROUP`](https://docs.cockroachlabs.com/docs/stable/alter-resource-group)
* [`SHOW RESOURCE GROUPS`](https://docs.cockroachlabs.com/docs/stable/show-resource-groups)
* [SQL Statements](https://docs.cockroachlabs.com/docs/stable/sql-statements.md)
