I'm wondering how to query the definition of a materialized view in Postgres. For reference, what I hoped to do is very similar to what you can do for a regular view:
SELECT * FROM information_schema.views WHERE table_name = 'some_view';
which gives you the following columns:
Is this possible for materialized views?
From my research so far, it appears that materialized views are deliberately excluded from information_schema, because
The information_schema can only show objects that exist in the SQL standard.
Since they appear to being entirely excluded from information_schema, I'm not sure how to go about this, but what I'd like to do is twofold:
- Query whether a particular materialized view exists. (So far the only way I've found to do this is try creating a mat view with the same name and see if it blows up.)
- And then query the definition of the materialized view (similar to the