gpt4 book ai didi

postgresql - 检查物化 View 是否存在?

转载 作者:行者123 更新时间:2023-11-29 13:07:58 30 4
gpt4 key购买 nike

如何检查物化 View 是否存在?

我创建了一个并 checkin 了 information_schema.tablesinformation_schema.views,但我看不到它。

我应该看哪里?

最佳答案

使用系统目录pg_class ,例如:

create materialized view my_view as select 1;

select relname, relkind
from pg_class
where relname = 'my_view'
and relkind = 'm';

relname | relkind
---------+---------
my_view | m
(1 row)

或系统 View pg_matviews:

select *
from pg_matviews
where matviewname = 'my_view';

schemaname | matviewname | matviewowner | tablespace | hasindexes | ispopulated | definition
------------+-------------+--------------+------------+------------+-------------+------------
public | my_view | postgres | | f | t | SELECT 1;
(1 row)

关于postgresql - 检查物化 View 是否存在?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58720894/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com