PostgreSQL – Get ddl of a view

You can query the system catalog table ‘views’ to get the definition of a view in postgres database.

SELECT view_definition FROM information_schema.views WHERE table_schema='your_view_schema' AND table_name='your_view_name';

See also  PostgreSQL - Change user password