检查物化视图是否存在?
Check a materialized view exists?
如何检查实体化视图是否存在?
我创建了一个并签入了 information_schema.tables
和 information_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)
或系统视图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)
如何检查实体化视图是否存在?
我创建了一个并签入了 information_schema.tables
和 information_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)
或系统视图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)