解决方法
显示所有:
SELECT oid::regclass::text FROM pg_class WHERE relkind = 'm';
根据您当前的search_path
,必要时,从命令转换为文本,名称将自动转义和模式限定.
系统目录pg_class中的物化视图由relkind =’m’标识.
Per documentation:
m = materialized view
SELECT 'DROP MATERIALIZED VIEW ' || string_agg(oid::regclass::text,',') FROM pg_class WHERE relkind = 'm';
返回:
DROP MATERIALIZED VIEW mv1,some_schema_not_in_search_path.mv2,...
一个DROP MATERIALIZED VIEW
语句可以处理多个物化视图.如果您有嵌套视图,则可能需要在最后添加CASCADE.