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

Ron Johnson <ronljohnsonjr@gmail.com>

From: Ron Johnson <ronljohnsonjr@gmail.com>
To: Pgsql-admin <pgsql-admin@lists.postgresql.org>
Date: 2026-05-14T17:20:12Z
Lists: pgsql-general
On Thu, May 14, 2026 at 11:07 AM Gambhir Singh <gambhir.singh05@gmail.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!