> ## 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 VIEW

The `DROP VIEW` [statement](/docs/stable/sql-statements.md) removes a [view](/docs/stable/views.md) from a database.

> [!NOTE]
>
> The `DROP VIEW` statement performs a schema change. For more information about how online schema changes work in CockroachDB, see [Online Schema Changes](/docs/stable/online-schema-changes.md).

## Required privileges

The user must have the `DROP` [privilege](/docs/stable/security-reference/authorization.md#managing-privileges) on the specified view(s). If `CASCADE` is used to drop dependent views, the user must have the `DROP` privilege on each dependent view as well.

## Synopsis

![drop\_view syntax diagram](https://mintcdn.com/cockroachlabs/UZNSFbmU2EwEm6G5/images/sql-diagrams/common/drop_view.svg?fit=max\&auto=format\&n=UZNSFbmU2EwEm6G5\&q=85\&s=80290d32c9d0f4fd815e451a8075f5ed)

## Parameters

| Parameter | Description |
| - | - |
| `MATERIALIZED` | Drop a [materialized view](/docs/stable/views.md#materialized-views). |
| `IF EXISTS` | Drop the view if it exists; if it does not exist, do not return an error. |
| `view_name_list` | A comma-separated list of view names. To find view names, use: `SELECT * FROM information_schema.tables WHERE table_type = 'VIEW';` |
| `CASCADE` | Drop other views that depend on the view being dropped. `CASCADE` does not list views it drops, so should be used cautiously. |
| `RESTRICT` | *(Default)* Do not drop the view if other views depend on it. |

## Examples

### Remove a view (no dependencies)

In this example, other views do not depend on the view being dropped.

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> SELECT * FROM information_schema.tables WHERE table_type = 'VIEW';
```

```
  table_catalog | table_schema |  table_name   | table_type | is_insertable_into | version
----------------+--------------+---------------+------------+--------------------+----------
  bank          | public       | user_accounts | VIEW       | NO                 |       2
  bank          | public       | user_emails   | VIEW       | NO                 |       1
(2 rows)
```

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> DROP VIEW bank.user_emails;
```

```
DROP VIEW
```

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> SELECT * FROM information_schema.tables WHERE table_type = 'VIEW';
```

```
  table_catalog | table_schema |  table_name   | table_type | is_insertable_into | version
----------------+--------------+---------------+------------+--------------------+----------
  bank          | public       | user_accounts | VIEW       | NO                 |       4
(1 row)
```

### Remove a view (with dependencies)

In this example, another view depends on the view being dropped. Therefore, it's only possible to drop the view while simultaneously dropping the dependent view using `CASCADE`.

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> SELECT * FROM information_schema.tables WHERE table_type = 'VIEW';
```

```
  table_catalog | table_schema |  table_name   | table_type | is_insertable_into | version
----------------+--------------+---------------+------------+--------------------+----------
  bank          | public       | user_accounts | VIEW       | NO                 |       2
  bank          | public       | user_emails   | VIEW       | NO                 |       1
(2 rows)
```

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> DROP VIEW bank.user_accounts;
```

```
ERROR: cannot drop relation "user_accounts" because view "user_emails" depends on it
SQLSTATE: 2BP01
```

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> DROP VIEW bank.user_accounts CASCADE;
```

```
DROP VIEW
```

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> SELECT * FROM information_schema.tables WHERE table_type = 'VIEW';
```

```
  table_catalog | table_schema | table_name | table_type | is_insertable_into | version
----------------+--------------+------------+------------+--------------------+----------
(0 rows)
```

## See also

* [Views](/docs/stable/views.md)
* [`CREATE VIEW`](/docs/stable/create-view)
* [`SHOW CREATE`](/docs/stable/show-create)
* [`ALTER VIEW`](/docs/stable/alter-view)
* [Online Schema Changes](/docs/stable/online-schema-changes.md)
