Show materialized view definition in #postgresql

May 31, 2018|
1 min read
  • sql

Originally posted by me on Hashrocket TIL

PSQL offers a handy \dv function for showing the definition of a view. That function does not seem to work on materialized views.

To see the definition of a materialized view use the following instead:

select pg_get_viewdef('search_documents');

Another option is to use \d+ search_documents which shows both the query and the columns.

(Replace search_documents with the name of your view.)


© 2023, Dorian Karter