The list of all the queries

Columns that have the same name as some domain/type

Query goal: Use different names to avoid confusion.
Notes about the query: 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.
Query type: Problem detection (Each row in the result could represent a flaw in the design)
Query reliability: Medium (Medium number of false-positive results)
Query license: MIT License
Fixing suggestion: Rename the column or the type/domain.
Data source: INFORMATION_SCHEMA+system catalog
SQL query: Click on query to copy it

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 where the query belongs to

Collection nameCollection description
Find problems about namesA 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 where the query belongs to

Category nameCategory description
Data typesQueries of this category provide information about the data types and their usage.
DomainsQueries of this category provide information about reusable specifications of column properties.
NamingQueries of this category provide information about the style of naming.

The list of all the queries