---
title: "DROP VIEW"
url: "https://docs.yugabyte.com/stable/api/ysql/the-sql-language/statements/ddl_drop_view/"
---

# DROP VIEW

Use the DROP VIEW statement to drop a view.

## Synopsis

Use the `DROP VIEW` statement to drop a view.

## Syntax

- [![Grammar Icon](/icons/file-lines.svg)Grammar](#grammar-2)
- [![Diagram Icon](/icons/diagram.svg)Diagram](#diagram-2)

```output.ebnf
drop_view ::= DROP VIEW [ IF EXISTS ] qualified_name  
              [ CASCADE | RESTRICT ]
```

#### drop\_view

DROPVIEWIFEXISTS[qualified\_name](/stable/api/ysql/syntax_resources/grammar_diagrams#qualified-name)CASCADERESTRICT

## Semantics

Drop a view named *qualified\_name*. If `qualified_name` doesn't exist in the specified database, an error will be raised unless the `IF EXISTS` clause is used.

### RESTRICT / CASCADE

`RESTRICT` is the default, and it will not drop the view if any objects depend on it.

`CASCADE` will drop any objects that transitively depend on the view.

## Examples

Basic example.

```plpgsql
yugabyte=# CREATE TABLE t1(a int4);
yugabyte=# CREATE VIEW m1 AS SELECT * FROM t1;
yugabyte=# CREATE VIEW m2 AS SELECT * FROM m1;
yugabyte=# DROP VIEW m1; -- fails because m2 depends on m1
```

```
ERROR:  cannot drop view m1 because other objects depend on it
DETAIL:  view m2 depends on view m1
HINT:  Use DROP ... CASCADE to drop the dependent objects too.
```

```plpgsql
yugabyte=# DROP VIEW m1 CASCADE; -- succeeds
```

## See also

- [CREATE VIEW](/stable/api/ysql/the-sql-language/statements/ddl_create_view "CREATE VIEW")
- [DROP MATERIALIZED VIEW](/stable/api/ysql/the-sql-language/statements/ddl_drop_matview/ "DROP MATERIALIZED VIEW")
