我想知道如何在 Postgres 中查询物化视图的定义。作为参考,我希望做的与您可以为常规视图做的非常相似:
SELECT * FROM information_schema.views WHERE table_name = 'some_view';
Run Code Online (Sandbox Code Playgroud)
它为您提供以下列:
table_catalog
table_schema
table_name
view_definition
check_option
is_updatable
is_insertable_into
is_trigger_updatable
is_trigger_deletable
is_trigger_insertable_into
Run Code Online (Sandbox Code Playgroud)
这对于物化视图是可能的吗?
从我目前的研究来看,物化视图似乎被故意排除在 information_schema 之外,因为
information_schema 只能显示存在于 SQL 标准中的对象。
( http://www.postgresql.org/message-id/3794.1412980686@sss.pgh.pa.us )
由于它们似乎完全被排除在 information_schema 之外,我不知道如何解决这个问题,但我想做的是双重的:
view_definition
列information_schema.views
)。postgresql materialized-view information-schema postgresql-9.4