WITH views AS (SELECT
views.table_schema,
views.table_name,
'VIEW' AS type,
views.view_definition
FROM
information_schema.views
WHERE table_schema NOT IN (SELECT schema_name
FROM INFORMATION_SCHEMA.schemata
WHERE schema_name<>'public' AND
schema_owner='postgres' AND schema_name IS NOT NULL)
UNION SELECT schemaname, matviewname, 'MATERIALIZED VIEW' AS type, definition
FROM pg_catalog.pg_matviews),
views_processed AS (SELECT
table_schema,
table_name,
type,
view_definition,
regexp_replace(view_definition,'[\r\n]',' ','g') AS view_definition_changed
FROM views)
SELECT table_schema, table_name, type, view_definition_changed AS view_definition
FROM views_processed
WHERE view_definition~*'JOIN'
AND view_definition!~*'USING[[:space:]]*[(]'
ORDER BY table_schema, table_name;
Categories
This query is classified under the following categories:
Name
Description
Comfortability of database evolution
Queries of this category provide information about the means that influence database evolution.
Derived tables
Queries of this category provide information about the derived tables (views, materialized views), which are used to implement virtual data layer.
Syntactics
Queries of this category provide information about syntactic mistakes.