Re: 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: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org>
Subject: Re: Help to find-the-maximum-length-of-field-in-a-particular-column-in-all the tables
Date: 2020-04-03 05:15:03
Message-ID: CANynezNqZbKhmOfC90g-qYQ9csP6YMP9EfFcPrERdNVj8LCs1g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-general

Thanks Joshuva and David.

Hi David,

We are trying to findout the max size of the data in columns for all tables
to resize the width of the assigned columns.

Regards,
Postgann.

On Fri, Apr 3, 2020 at 2:29 AM David G. Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
wrote:

> Please just choose a single list to email.
>
> On Thursday, April 2, 2020, postgann2020 s <postgann2020(at)gmail(dot)com> wrote:
>
>> Hi Team,
>>
>> Good Evening,
>>
>> We are trying to syncing the table field size with other db tables filed
>> size.
>>
>
> I wouldn’t bother fiddling with arbitrary sizes, just remove,them.
>
>
>> 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.
>>
>
> You need to decide whether you want to query table data or catalog
> (schema) data.
>
>
>>
>> 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;
>>
>>
> If you want to dynamically determine tables and columns while still
> checking the actual table data you will need to create a dynamic sql
> statement to query the actual table with the content for the dynamic schema
> parts being populated by a query against information_schema or the
> catalog. You’d need you something besdies pure sql (e.g., pl/pgsql) to do
> this. You may find it easier to just brute force things.
>
> David J.
>

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Ishan joshi 2020-04-03 06:19:56 Can we extract CPU usage by table/query level
Previous Message postgann2020 s 2020-04-03 05:11:52 Re: 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 Andrus 2020-04-03 06:37:39 Re: Fixing set-returning functions are not allowed in UPDATE after upgrade to Postgres 12
Previous Message postgann2020 s 2020-04-03 05:11:52 Re: Could someone please help us share the procedure to troubleshoot the locks on proc issues.