Hi, 

In pgAdmin4 you can view the query needed to create a table, view, etc. by selecting the SQL tab.
I assume in pgAdmin4 this SQL view is build using a query.
Is it possible to publish this query. Probably this query is something like this:

SELECT 'CREATE OR REPLACE VIEW ' || pg_views.schemaname || '.' || pg_views.viewname || ' AS ' || chr(10) ||
pg_views.definition || chr(10) ||
'ALTER TABLE ' || pg_views.schemaname || '.' || pg_views.viewname || ' OWNER TO ' || pg_views.viewowner || ';' ||
chr(10) || 'COMMENT ON VIEW ' || pg_views.schemaname || '.' || pg_views.viewname|| chr(10) ||
' IS ''' || CASE WHEN obj_description(pg_class.oid) != '' THEN obj_description(pg_class.oid) ELSE 'No description' END || ''';' || chr(10)
FROM pg_views
JOIN pg_class ON pg_class.relname=pg_views.viewname
JOIN pg_namespace ON pg_class.relnamespace=pg_namespace.oid
WHERE pg_namespace.nspname = LOWER('{schema}');

I tried to complete the query but the only part I'm missing is the GRANT statements. It should be very helpful if I could have this query. 

Kind regards,
Henk F. van Til



Reply via email to