Goal Find derived tables that use newer join syntax where join conditions are written in the WHERE clause but do not use USING synatx.
Type Problem detection (Each row in the result could represent a flaw in the design)
Reliability Low (Many false-positive results)
License MIT License
Data Source INFORMATION_SCHEMA+system catalog
SQL Query
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:

NameDescription
Comfortability of database evolutionQueries of this category provide information about the means that influence database evolution.
Derived tablesQueries of this category provide information about the derived tables (views, materialized views), which are used to implement virtual data layer.
SyntacticsQueries of this category provide information about syntactic mistakes.

Further reading and related materials:

Reference
https://www.neilwithdata.com/join-using