<a id="flink-sql-drop-view"></a>

# DROP VIEW Statement in Confluent Cloud for Apache Flink

Confluent Cloud for Apache Flink® enables dropping views using the DROP VIEW statement.
When a view is dropped, its definition is removed from the catalog.
The corresponding Kafka topic Flink resource reservation is removed.
Any statement that you submit after the view is dropped fails if it
references the dropped view.

## Syntax

```sql
DROP VIEW [IF EXISTS] [catalog_name.][db_name.]view_name
```

## Description

DROP VIEW removes a view from the catalog. If the view does not exist,
an exception is thrown unless `IF EXISTS` is specified.

#### NOTE
Dropping a view doesn’t affect Flink SQL statements that are already
running and reference the view. Like other catalog objects, a running
statement takes a snapshot of the view’s definition when the statement
starts. The statement keeps running against that snapshot even after
you drop the view. For more information, see
[Statements take a snapshot of their dependencies](../../concepts/schema-statement-evolution.md#flink-sql-schema-and-statement-evolution-dependency-snapshot).

The view name can be in these formats:

- `catalog_name.db_name.view_name`: The view with the given name is dropped
  from the catalog named “catalog_name” and the database named “db_name”.
- `db_name.view_name`: The view with the given name is dropped from the
  current catalog of the execution table environment and the database named
  “db_name”.
- `view_name`: The view with the given name is dropped from the current
  catalog and the current database of the execution table environment.

<a id="flink-sql-drop-view-examples"></a>

## Examples

The following example drops the `vip_customers` view.

In the Confluent CLI or in a Cloud Console workspace, run the
following command:

```sql
DROP VIEW vip_customers;
```

Your output should resemble:

```none
Statement phase is COMPLETED.
```

If you try to query the dropped view:

```sql
SELECT * FROM vip_customers;
```

You receive an error message indicating that the view does not exist:

```none
[Code: 1, SQL State: 42000]: Object 'default_catalog.default_database.vip_customers' does not exist.
```

To avoid the error when dropping a view that may not exist, use the
`IF EXISTS` clause:

```sql
DROP VIEW IF EXISTS vip_customers;
```

This statement does not throw an error if the `vip_customers` view does not
exist.

## Related content

- [CREATE VIEW](create-view.md#flink-sql-create-view)
- [ALTER VIEW](alter-view.md#flink-sql-alter-view)
- [Schema and Statement Evolution](../../concepts/schema-statement-evolution.md#flink-sql-schema-and-statement-evolution)

#### NOTE
This website includes content developed at the [Apache Software Foundation](https://www.apache.org/)
under the terms of the [Apache License v2](https://www.apache.org/licenses/LICENSE-2.0.html).
