The query does not consider the columns of materialized views. The query does not check whether the column name and the name of the type of the column is the same.
Type
Problem detection (Each row in the result could represent a flaw in the design)
WITH column_names AS (SELECT table_schema, table_name, column_name, data_type
FROM INFORMATION_SCHEMA.columns
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)),
type_names AS (SELECT nspname AS type_schema, typname AS type_name, typtype
FROM pg_catalog.pg_type t INNER JOIN pg_catalog.pg_namespace n ON t.typnamespace=n.oid
WHERE typtype<>'c' AND typname<>'name')
SELECT table_schema, table_name, column_name, data_type AS column_type, type_schema, type_name,
CASE WHEN typtype='b' THEN 'BASE TYPE'
WHEN typtype='d' THEN 'DOMAIN'
WHEN typtype='e' THEN 'ENUMERATION TYPE'
WHEN typtype='p' THEN 'PSEUDO TYPE'
ELSE 'RANGE TYPE' END AS type_type
FROM column_names, type_names
WHERE lower(column_name)=lower(type_name)
ORDER BY table_schema, table_name;
Collections
This query belongs to the following collections:
Name
Description
Find problems about names
A selection of queries that return information about the names of database objects. Contains all the types of queries - problem detection, software measure, and general overview.
Categories
This query is classified under the following categories:
Name
Description
Data types
Queries of this category provide information about the data types and their usage.
Domains
Queries of this category provide information about reusable specifications of column properties.
Naming
Queries of this category provide information about the style of naming.