Help to find-the-maximum-length-of-field-in-a-particular-column-in-allthe tables - Mailing list pgsql-admin

From postgann2020 s
Subject Help to find-the-maximum-length-of-field-in-a-particular-column-in-allthe tables
Date
Msg-id CANynezP9ND2xh4Jn9cToki0RYm8=8PeqLSO_8dv0Lde3Fu9ozQ@mail.gmail.com
Whole thread Raw
Responses Re: Help to find-the-maximum-length-of-field-in-a-particular-column-in-allthe tables
Re: Help to find-the-maximum-length-of-field-in-a-particular-column-in-allthe tables
List pgsql-admin
Hi Team,

Good Evening,

We are trying to syncing the table field size with other db tables filed size.

We have multiple tables in multiple schemas in DB. we are tyring to findout maximum size of each column in table for all tables and for all schemas in DB.

How to find the maximum length of data field in a particular column in a table and for all tables in schema.

Example column names in table: a,b,c,d,e,f,g
Example schema names in DB: A,B,C,D

Expected output:
column_name Max_size_of_column
a 10
b 20

or
column_name, Max_size_of_column, column_table, table_schema
a 10 Table1 Schema1
b 20 Table1 Schema1

I have tried below query, but not able to get desired output.

SELECT (select column_name from INFORMATION_SCHEMA.COLUMNS where table_name='building'), select max(length(select column_name from INFORMATION_SCHEMA.COLUMNS where table_name='building')) from from INFORMATION_SCHEMA.COLUMNS where table_name='building'
group by column_name;

Please help us to get the desired output.

Below is the reference i have used for above one. https://stackoverflow.com/questions/43123311/how-to-find-the-maximum-length-of-data-in-a-particular-field-in-postgresql

Regards,
Postgann.  

pgsql-admin by date:

Previous
From: Ashutosh Sharma
Date:
Subject: Re: PG query to count all objects
Next
From: "David G. Johnston"
Date:
Subject: Re: Help to find-the-maximum-length-of-field-in-a-particular-column-in-allthe tables