How to do it...

First, we will show you how to identify columns that are defined in different ways in different tables, using a query against the catalog. We use an information_schema query, as follows:

SELECT table_schema,table_name,column_name,data_type  ||coalesce(' ' || text(character_maximum_length), '')  ||coalesce(' ' || text(numeric_precision), '')  ||coalesce(',' || text(numeric_scale), '')  as data_typeFROM information_schema.columnsWHERE column_name IN(SELECT column_nameFROM(SELECT  column_name ,data_type ,character_maximum_length ,numeric_precision ,numeric_scale FROM information_schema.columns WHERE table_schema NOT IN ('information_schema', 'pg_catalog') GROUP BY  column_name ,data_type ,character_maximum_length ,numeric_precision ...

Get PostgreSQL 10 Administration Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.