1

Is there a way to discover the structure of a view in a similar way to how tables are described by entries in information_schema.columns? I can also use the pg_* tables.

In other words, similar to how psql has \d which describes the structures of both tables and views, I'd like to access this information via SQL queries.

2
  • My goal is not to see the SELECT query which makes the view (that's already available in pg_views, but the columns and their attributes.
    – Ivan Voras
    Sep 28, 2020 at 14:43
  • 2
    Just as a side note, when you specify -E to psql, it will print the query it uses for internal commands like \d
    – eckes
    Sep 28, 2020 at 15:46

1 Answer 1

2

information_schema.columns already includes views; you can join with information_schema.views if you need to filter to only columns that are part of a view.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.