Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

PostgreSQL – Get DDL for materialized view

I need to be able to get the DDL from a materialized view. We are wanting to track how often a MV gets updated/changed, and I want to be able to automate this process. I just need the DDL for the MV, not the column names/select statement.

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You can get the view definition like this:

SELECT pg_get_viewdef('schemaname.mvname');

To get the complete DDL statement, prepend the following:

CREATE MATERIALIZED VIEW schemaname.mvname AS

The only way to track changes in a materialized view definition would be to create an event trigger on ddl_command_end.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading