How to Get a View Definition in Redshift

Last updated August 20, 2026 · By the SaturnSQL team

SHOW VIEW schema.view_name returns the SQL behind any Redshift view, including late-binding and materialized views. pg_get_viewdef does the same inside a query, and the pg_views catalog lists every view with its definition so you can search them.

SHOW VIEW sales.active_users;

Inside a query with pg_get_viewdef

pg_get_viewdef returns the definition as a value, which is handy when you want it as part of a larger query. The second argument pretty-prints it.

SELECT pg_get_viewdef('sales.active_users'::regclass, true);

List every view with its definition

pg_views covers all regular and late-binding views. Filtering out the system schemas keeps the list to your own views, and ILIKE on the definition finds every view that touches a given table.

SELECT schemaname, viewname, definition
FROM pg_views
WHERE schemaname NOT IN ('pg_catalog', 'information_schema')
  AND definition ILIKE '%orders%';

Materialized views

SHOW VIEW works on materialized views too and returns the SELECT they were created with. Remember that a materialized view holds data, not just a definition: after changing the underlying tables, run REFRESH MATERIALIZED VIEW to bring it up to date.

SHOW VIEW sales.daily_revenue_mv;
REFRESH MATERIALIZED VIEW sales.daily_revenue_mv;

Run this in SaturnSQL

SaturnSQL is a browser-based SQL editor for teams: shared query library, schema-aware autocomplete, and scheduled exports to Google Sheets and Slack.

Try it free

Do more with Redshift

Related Redshift guides