删除视图示例
最近更新时间: 2025-02-18 16:02:00
postgres=# drop table t;
DROP TABLE
postgres=# create table t (id int,mc text);
CREATE TABLE
postgres=# create view t_view as select * from t;
CREATE VIEW
postgres=# create view t_view_1 as select * from t_view;
CREATE VIEW
postgres=# create view t_view_2 as select * from t_view;
CREATE VIEW
postgres=# drop view t_view_2;
DROP VIEW
#使用cascade强制删除依赖对象
postgres=# drop view t_view;
ERROR: cannot drop view t_view because other objects depend on it
DETAIL: view t_view_1 depends on view t_view
HINT: Use DROP ... CASCADE to drop the dependent objects too.
postgres=# drop view t_view cascade;
NOTICE: drop cascades to view t_view_1
DROP VIEW