DROP MATERIALIZED VIEW 是一个用于删除物化视图的 DDL 命令。
DROP MATERIALIZED VIEW 于 PostgreSQL 9.3 中添加。
示例
DROP MATERIALIZED VIEW 的基本用法示例
postgres=# DROP MATERIALIZED VIEW bar; DROP MATERIALIZED VIEW
尝试删除具有依赖关系的物化视图
postgres=# DROP MATERIALIZED VIEW bar; ERROR: cannot drop materialized view bar because other objects depend on it DETAIL: materialized view bar2 depends on materialized view bar HINT: Use DROP ... CASCADE to drop the dependent objects too.
尝试删除不存在的物化视图
postgres=# DROP MATERIALIZED VIEW boo; ERROR: materialized view "boo" does not exist
尝试在一个非物化视图的对象上执行 DROP MATERIALIZED VIEW
postgres=# DROP MATERIALIZED VIEW foo; ERROR: "foo" is not a materialized view HINT: Use DROP TABLE to remove a table.
参考资料
- PostgreSQL 文档: DROP MATERIALIZED VIEW
