PostgreSQL – How to Inspect a View’s Structure in Information Schema

information-schemapostgresql

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.

Best Answer

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.