select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

FUNCTIONS / SYSTEM INFORMATION FUNCTIONS AND OPERATORS

pg_get_viewdef

Read PG 18 manual ↗

Reconstructs the underlying SELECT command for a view or materialized view.

Signatures & examples

pg_get_viewdef ( view oid [, pretty boolean ] ) → text
Reconstructs the underlying SELECT command for a view or materialized view. (This is a decompiled reconstruction, not the original text of the command.)
pg_get_viewdef ( view oid, wrap_column integer ) → text
Reconstructs the underlying SELECT command for a view or materialized view. (This is a decompiled reconstruction, not the original text of the command.) In this form of the function, pretty-printing is always enabled, and long lines are wrapped to try to keep them shorter than the specified number of columns.
pg_get_viewdef ( view text [, pretty boolean ] ) → text
Reconstructs the underlying SELECT command for a view or materialized view, working from a textual name for the view rather than its OID. (This is deprecated; use the OID variant instead.)
Version history 3
  1. PG 12 → 13changed
  2. PG 9.2 → 9.3changed
  3. PG 9.1 → 9.2changed

Definition snapshot: 2026-09-14T13:14:25.684213+00:00@99e6866c · English manual source