DROP VIEW
是用于删除视图的 DDL 命令。
DROP VIEW
一直存在于 PostgreSQL 中。
更改历史
- PostgreSQL 8.2
DROP VIEW IF EXISTS ...
语法添加(提交 daea4d8e)
- PostgreSQL 7.3
CASCADE
和RESTRICT
子句添加(提交 131f801d)
示例
基本 DROP VIEW
执行
postgres=# DROP VIEW bar; DROP VIEW
安全地尝试删除可能不存在的视图
postgres=# DROP VIEW IF EXISTS bar; NOTICE: view "bar" does not exist, skipping DROP VIEW
删除具有依赖项的视图
postgres=# DROP VIEW bar; ERROR: cannot drop view bar because other objects depend on it DETAIL: view baz depends on view bar HINT: Use DROP ... CASCADE to drop the dependent objects too. postgres=# DROP VIEW bar CASCADE; NOTICE: drop cascades to view baz DROP VIEW
参考
- PostgreSQL 文档: DROP VIEW