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

# DROP VIRTUAL CLUSTER

export const InternalLink = ({version, path = "", children, ...props}) => {
  let detectedVersion = version || "stable";
  if (typeof window !== 'undefined' && !version) {
    const match = window.location.pathname.match(/\/docs\/([^/]+)/);
    if (match) {
      detectedVersion = match[1];
    }
  }
  const normalizedPath = path.startsWith("/") ? path.slice(1) : path;
  return <a href={`/docs/${detectedVersion}/${normalizedPath}`} {...props}>
      {children}
    </a>;
};

export const version = "v26.1";

<Note>
  **This feature is in <InternalLink path="cockroachdb-feature-availability">preview</InternalLink>** and subject to change. To share feedback and/or issues, contact [Support](https://support.cockroachlabs.com).
</Note>

The `DROP VIRTUAL CLUSTER` statement removes virtual clusters in order to restart a **physical cluster replication (PCR)** stream. Virtual clusters are used only as part of the <InternalLink path="physical-cluster-replication-overview">PCR</InternalLink> workflow.

PCR happens between an *active* primary cluster and a *passive* standby cluster that accepts updates from the primary cluster. The unit of replication is a *virtual cluster*, which is part of the underlying infrastructure in the primary and standby clusters. The CockroachDB cluster has:

* The system virtual cluster manages the cluster's control plane and the replication of the cluster's data. Admins connect to the system virtual cluster to configure and manage the underlying CockroachDB cluster, set up PCR, create and manage a virtual cluster, and observe metrics and logs for the CockroachDB cluster and each virtual cluster.
* The application virtual cluster manages the cluster’s data plane. Application virtual clusters contain user data and run application workloads.

For more detail, refer to the <InternalLink path="physical-cluster-replication-overview">Physical Cluster Replication Overview</InternalLink>.

<Danger>
  The `DROP VIRTUAL CLUSTER` statement will delete all data related to the specified virtual cluster.
</Danger>

## Required privileges

`DROP VIRTUAL CLUSTER` requires one of the following privileges:

* The `admin` role.
* The `MANAGEVIRTUALCLUSTER` <InternalLink path="security-reference/authorization#privileges">system privilege</InternalLink>.

Use the <InternalLink path="grant">`GRANT SYSTEM`</InternalLink> statement:

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
GRANT SYSTEM MANAGEVIRTUALCLUSTER TO user;
```

## Synopsis

xml version="1.0" encoding="UTF-8"?

<DropVirtualCluster />

## Parameters

| Parameter                | Description                                                                                                                                            |
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `IF EXISTS`              | Drop a virtual cluster if it exists. If it does not exist, do not return an error.                                                                     |
| `virtual\_cluster\_spec` | The name of the virtual cluster.                                                                                                                       |
| `IMMEDIATE`              | Drop a virtual cluster immediately instead of waiting for garbage collection (<InternalLink path="configure-replication-zones">GC TTL</InternalLink>). |

## Examples

### Restart a PCR stream

To restart a PCR stream, drop the virtual cluster:

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
DROP VIRTUAL CLUSTER IF EXISTS main;
```

Next, restart the PCR stream with the <InternalLink path="create-virtual-cluster">`CREATE VIRTUAL CLUSTER`</InternalLink> syntax:

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
CREATE VIRTUAL CLUSTER main FROM REPLICATION OF main ON 'postgresql://{connection string to primary}';
```

### Remove a virtual cluster without waiting for garbage collection

Use `IMMEDIATE` to drop a virtual cluster instead of waiting for data to be garbage collected:

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
DROP VIRTUAL CLUSTER IF EXISTS main IMMEDIATE;
```

## See also

* <InternalLink path="create-virtual-cluster">`CREATE VIRTUAL CLUSTER`</InternalLink>
* <InternalLink path="alter-virtual-cluster">`ALTER VIRTUAL CLUSTER`</InternalLink>
* <InternalLink path="show-virtual-cluster">`SHOW VIRTUAL CLUSTER`</InternalLink>
