Help to find-the-maximum-length-of-field-in-a-particular-column-in-all the tables

From: postgann2020 s <postgann2020(at)gmail(dot)com>
To: pgsql-admin(at)postgresql(dot)org, pgsql-general(at)postgresql(dot)org
Subject: Help to find-the-maximum-length-of-field-in-a-particular-column-in-all the tables
Date: 2020-04-02 19:51:06
Message-ID: CANynezP9ND2xh4Jn9cToki0RYm8=8PeqLSO_8dv0Lde3Fu9ozQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-general

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.

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message David G. Johnston 2020-04-02 20:59:53 Re: Help to find-the-maximum-length-of-field-in-a-particular-column-in-all the tables
Previous Message postgann2020 s 2020-04-02 19:37:43 Could someone please help us share the procedure to troubleshoot the locks on proc issues.

Browse pgsql-general by date

  From Date Subject
Next Message Moses Mafusire 2020-04-02 20:40:11 Cstore_fdw issue.
Previous Message postgann2020 s 2020-04-02 19:37:43 Could someone please help us share the procedure to troubleshoot the locks on proc issues.