PostgreSQL – Definition of a Materialized View

I often get to work with different clients and different technologies when I am busy with Comprehensive Database Performance Health Check. Recently, during a consultation, I had to work with PostgreSQL and we needed to find the Definition of a Materialized View.

Well in the earlier version of PostgreSQL, it was not possible to list all the materialized views as well as its definition. However, in the latest version of PostgreSQL, it is now possible to do that with the system view. Here is the script to list the Definition of a Materialized View.

SELECT *
FROM pg_matviews;

The script above will give much important information. It will show if the view has any indexes or if the view has any data in it or not.

Here are my few recent videos and I would like to know what is your feedback about them. Do not forget to subscribe SQL in Sixty Seconds series. I hope you appreciate learning about the Last 5 SQL in Sixty Seconds Video.

Reference: Pinal Dave (http://blog.SQLAuthority.com)

Menu
Exit mobile version