Re: Alter the datatype on all tables present in the database (bigint to varchar)

From: Ron Johnson <ronljohnsonjr(at)gmail(dot)com>
To: Pgsql-admin <pgsql-admin(at)lists(dot)postgresql(dot)org>
Subject: Re: Alter the datatype on all tables present in the database (bigint to varchar)
Date: 2026-05-14 17:20:12
Message-ID: CANzqJaBiSXdTSzYS18fc_XUHKUHPkhBu-uz2cW691BLSHnbydw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-general

On Thu, May 14, 2026 at 11:07 AM Gambhir Singh <gambhir(dot)singh05(at)gmail(dot)com>
wrote:

> Hi,
>
> Please help me with the best way to change the datatype of a column in a
> all tables in DB from bigint to varchar. Please consider the following
> facts.
>
>
> - DB Size - 75 TB
> - Number of tables - ~100
> - Some tables are partitioned and some are not partitioned.
> - All partitioned tables are big in size.
> - For reference, the largest partition size is 4 TB, similarly the
> size of 10-12 partitions ranges between 1 to 4 TB.
> - We have indexes and FK on tables.
>
>
With tables that big, and all those FK constraints, logical replication is
probably your only hope for minimal downtime.

If you're running an older major version, this would also be a good time to
upgrade to 17.latest or 18.latest.

And Adrian's question is quite valid: *why*? Normally, people go the
other way, for efficiency.

>
> - Physical Replication is configured with 2 standby DBs.
>
> At least you have an existing server with enough disk space!!!

--
Death to <Redacted>, and butter sauce.
Don't boil me, I'm still alive.
<Redacted> lobster!

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Ron Johnson 2026-05-14 20:05:48 Are these metadata ALTER TABLE commands transactionally safe?
Previous Message Adrian Klaver 2026-05-14 17:00:28 Re: Alter the datatype on all tables present in the database (bigint to varchar)

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2026-05-14 17:26:45 Re: pgBackRest maintenance (was Re: Tablespace size in TB)
Previous Message Adrian Klaver 2026-05-14 17:00:28 Re: Alter the datatype on all tables present in the database (bigint to varchar)