Bare:
SELECT pg_get_viewdef('myview');
fra klienten efter eget valg.
for eksempel. i psql
:
test=> CREATE MATERIALIZED VIEW fred AS SELECT x FROM generate_series(1,100) x;
SELECT 100
test=> \a\t
Output format is unaligned.
Showing only tuples.
test=> SELECT pg_get_viewdef('fred');
SELECT x.x
FROM generate_series(1, 100) x(x);
Dette fungerer for normale og materialiserede visninger.
Som Richard siger, brug alternativt psql
's \d+
, som kalder pg_get_viewdef
bag kulisserne.